File Coverage

blib/lib/Log/Log4perl/Appender/TestArrayBuffer.pm
Criterion Covered Total %
statement 9 10 90.0
branch 2 4 50.0
condition n/a
subroutine 2 2 100.0
pod 0 1 0.0
total 13 17 76.4


line stmt bran cond sub pod time code
1             ##################################################
2             ##################################################
3             # Like Log::Log4perl::Appender::TestBuffer, just with
4             # array capability.
5             # For testing only.
6             ##################################################
7              
8             use base qw( Log::Log4perl::Appender::TestBuffer );
9 1     1   7  
  1         4  
  1         258  
10             ##################################################
11             ##################################################
12             my $self = shift;
13             my %params = @_;
14 3     3 0 6  
15 3         11 $self->{buffer} .= "[$params{level}]: " if $LOG_PRIORITY;
16              
17 3 50       8 if(ref($params{message}) eq "ARRAY") {
18             $self->{buffer} .= "[" . join(',', @{$params{message}}) . "]";
19 3 50       43 } else {
20 3         8 $self->{buffer} .= $params{message};
  3         18  
21             }
22 0           }
23              
24             1;
25              
26             =encoding utf8
27              
28             =head1 NAME
29              
30             Log::Log4perl::Appender::TestArrayBuffer - Subclass of Appender::TestBuffer
31              
32             =head1 SYNOPSIS
33              
34             use Log::Log4perl::Appender::TestArrayBuffer;
35              
36             my $appender = Log::Log4perl::Appender::TestArrayBuffer->new(
37             name => 'buffer',
38             );
39              
40             # Append to the buffer
41             $appender->log(
42             level = > 'alert',
43             message => ['first', 'second', 'third'],
44             );
45              
46             # Retrieve the result
47             my $result = $appender->buffer();
48              
49             # Reset the buffer to the empty string
50             $appender->reset();
51              
52             =head1 DESCRIPTION
53              
54             This class is a subclass of Log::Log4perl::Appender::TestBuffer and
55             just provides message array refs as an additional feature.
56              
57             Just like Log::Log4perl::Appender::TestBuffer,
58             Log::Log4perl::Appender::TestArrayBuffer is used for internal
59             Log::Log4perl testing only.
60              
61             =head1 LICENSE
62              
63             Copyright 2002-2013 by Mike Schilli E<lt>m@perlmeister.comE<gt>
64             and Kevin Goess E<lt>cpan@goess.orgE<gt>.
65              
66             This library is free software; you can redistribute it and/or modify
67             it under the same terms as Perl itself.
68              
69             =head1 AUTHOR
70              
71             Please contribute patches to the project on Github:
72              
73             http://github.com/mschilli/log4perl
74              
75             Send bug reports or requests for enhancements to the authors via our
76              
77             MAILING LIST (questions, bug reports, suggestions/patches):
78             log4perl-devel@lists.sourceforge.net
79              
80             Authors (please contact them via the list above, not directly):
81             Mike Schilli <m@perlmeister.com>,
82             Kevin Goess <cpan@goess.org>
83              
84             Contributors (in alphabetical order):
85             Ateeq Altaf, Cory Bennett, Jens Berthold, Jeremy Bopp, Hutton
86             Davidson, Chris R. Donnelly, Matisse Enzer, Hugh Esco, Anthony
87             Foiani, James FitzGibbon, Carl Franks, Dennis Gregorovic, Andy
88             Grundman, Paul Harrington, Alexander Hartmaier David Hull,
89             Robert Jacobson, Jason Kohles, Jeff Macdonald, Markus Peter,
90             Brett Rann, Peter Rabbitson, Erik Selberg, Aaron Straup Cope,
91             Lars Thegler, David Viner, Mac Yang.
92