Log4perl/Appender/TestArrayBuffer.pm

filter: Statementstmt 90.9% 10 / 11 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod 0.0% 0 / 1 totaltotal 77.7% 14 / 18 CC 3 SCAR 9.7
CC
3
Cov
80%
log
3.2
BEGIN
1.0
CRAP 2.6
« Log4perl/NDC.pm ↑ Summary Log4perl/Layout.pm »
1 ##################################################
2 package Log::Log4perl::Appender::TestArrayBuffer;
3 ##################################################
4 # Like Log::Log4perl::Appender::TestBuffer, just with
5 # array capability.
6 # For testing only.
7 ##################################################
8  
9 1 ▶use base qw( Log::Log4perl::Appender::TestBuffer );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 ##################################################
12 3 ▶sub log {
Subroutine log: called CC=3 SCAR=11.6
Pod undocumented
13 ##################################################
14 3 my $self = shift;
15 3 my %params = @_;
16  
17 3 ▶ $self->{buffer} .= "[$params{level}]: " if $LOG_PRIORITY;
Branch: 1 branch
BranchTrueFalseTotal
if $LOG_PRIORITY 0 3 3
18  
19 3 ▶ if(ref($params{message}) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $params{'message'} eq 'ARRAY') { } 3 0 3
20 3 $self->{buffer} .= "[" . join(',', @{$params{message}}) . "]";
21 } else {
22 0 $self->{buffer} .= $params{message};
23 }
24 }
25  
26 1 1;
27  
28 =encoding utf8
29  
30 =head1 NAME
31  
32 Log::Log4perl::Appender::TestArrayBuffer - Subclass of Appender::TestBuffer
33  
34 =head1 SYNOPSIS
35  
36 use Log::Log4perl::Appender::TestArrayBuffer;
37  
38 my $appender = Log::Log4perl::Appender::TestArrayBuffer->new(
39 name => 'buffer',
40 );
41  
42 # Append to the buffer
43 $appender->log(
44 level = > 'alert',
45 message => ['first', 'second', 'third'],
46 );
47  
48 # Retrieve the result
49 my $result = $appender->buffer();
50  
51 # Reset the buffer to the empty string
52 $appender->reset();
53  
54 =head1 DESCRIPTION
55  
56 This class is a subclass of Log::Log4perl::Appender::TestBuffer and
57 just provides message array refs as an additional feature.
58  
59 Just like Log::Log4perl::Appender::TestBuffer,
60 Log::Log4perl::Appender::TestArrayBuffer is used for internal
61 Log::Log4perl testing only.
62  
63 =head1 LICENSE
64  
65 Copyright 2002-2026 by Mike Schilli E<lt>m@perlmeister.comE<gt>
66 and Kevin Goess E<lt>cpan@goess.orgE<gt>.
67  
68 This library is free software; you can redistribute it and/or modify
69 it under the same terms as Perl itself.
« Log4perl/NDC.pm ↑ Summary Log4perl/Layout.pm »