File Coverage

blib/lib/Log/Log4perl/Layout/PatternLayout/Multiline.pm
Criterion Covered Total %
statement 10 10 100.0
branch 1 2 50.0
condition n/a
subroutine 2 2 100.0
pod 0 1 0.0
total 13 15 86.6


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