• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /macosx-10.10.1/CPANInternal-159.1/Log-Log4perl-1.40/lib/Log/Log4perl/Layout/PatternLayout/
1#!/usr/bin/perl
2
3package Log::Log4perl::Layout::PatternLayout::Multiline;
4use base qw(Log::Log4perl::Layout::PatternLayout);
5
6###########################################
7sub render {
8###########################################
9    my($self, $message, $category, $priority, $caller_level) = @_;
10
11    my @messages = split /\r?\n/, $message;
12
13    $caller_level = 0 unless defined $caller_level;
14
15    my $result = '';
16
17    for my $msg ( @messages ) {
18        $result .= $self->SUPER::render(
19            $msg, $category, $priority, $caller_level + 1
20        );
21    }
22    return $result;
23}
24
251;
26
27__END__
28
29=head1 NAME
30
31    Log::Log4perl::Layout::PatternLayout::Multiline
32
33=head1 SYNOPSIS
34
35    use Log::Log4perl::Layout::PatternLayout::Multiline;
36
37    my $layout = Log::Log4perl::Layout::PatternLayout::Multiline->new(
38        "%d (%F:%L)> %m");
39
40=head1 DESCRIPTION
41
42C<Log::Log4perl::Layout::PatternLayout::Multiline> is a subclass
43of Log4perl's PatternLayout and is helpful if you send multiline
44messages to your appenders which appear as
45
46    2007/04/04 23:59:01 This is
47    a message with
48    multiple lines
49
50and you want them to appear as
51
52    2007/04/04 23:59:01 This is
53    2007/04/04 23:59:01 a message with
54    2007/04/04 23:59:01 multiple lines
55
56instead. This layout class simply splits up the incoming message into
57several chunks split by line breaks and renders them with PatternLayout
58just as if it had arrived in separate chunks in the first place.
59
60=head1 LICENSE
61
62Copyright 2002-2012 by Mike Schilli E<lt>m@perlmeister.comE<gt>
63and Kevin Goess E<lt>cpan@goess.orgE<gt>.
64
65This library is free software; you can redistribute it and/or modify
66it under the same terms as Perl itself.
67
68=head1 AUTHOR
69
70Please contribute patches to the project on Github:
71
72    http://github.com/mschilli/log4perl
73
74Send bug reports or requests for enhancements to the authors via our
75
76MAILING LIST (questions, bug reports, suggestions/patches):
77log4perl-devel@lists.sourceforge.net
78
79Authors (please contact them via the list above, not directly):
80Mike Schilli <m@perlmeister.com>,
81Kevin Goess <cpan@goess.org>
82
83Contributors (in alphabetical order):
84Ateeq Altaf, Cory Bennett, Jens Berthold, Jeremy Bopp, Hutton
85Davidson, Chris R. Donnelly, Matisse Enzer, Hugh Esco, Anthony
86Foiani, James FitzGibbon, Carl Franks, Dennis Gregorovic, Andy
87Grundman, Paul Harrington, David Hull, Robert Jacobson, Jason Kohles,
88Jeff Macdonald, Markus Peter, Brett Rann, Peter Rabbitson, Erik
89Selberg, Aaron Straup Cope, Lars Thegler, David Viner, Mac Yang.
90
91