line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::Log4perl::Appender::TAP; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6417
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
5
|
1
|
|
|
1
|
|
20
|
use 5.008001; |
|
1
|
|
|
|
|
3
|
|
6
|
1
|
|
|
1
|
|
5
|
use Test2::API qw( context ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
7
|
1
|
|
|
1
|
|
6
|
use parent qw( Log::Log4perl::Appender ); |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
6
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Append to TAP output |
10
|
|
|
|
|
|
|
our $VERSION = '0.05'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new |
14
|
|
|
|
|
|
|
{ |
15
|
3
|
|
|
3
|
1
|
2293
|
my $proto = shift; |
16
|
3
|
|
33
|
|
|
21
|
my $class = ref $proto || $proto; |
17
|
3
|
|
|
|
|
10
|
my %args = @_; |
18
|
|
|
|
|
|
|
bless { |
19
|
3
|
|
100
|
|
|
19
|
method => $args{method} || 'note', |
20
|
|
|
|
|
|
|
}, $class; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub log |
24
|
|
|
|
|
|
|
{ |
25
|
2
|
|
|
2
|
0
|
22196
|
my $self = shift; |
26
|
2
|
|
|
|
|
9
|
my %args = @_; |
27
|
2
|
|
|
|
|
9
|
my $method = $self->{method}; |
28
|
2
|
|
|
|
|
5
|
my $ctx = context(); |
29
|
2
|
|
|
|
|
186
|
$ctx->$method($args{message}); |
30
|
2
|
|
|
|
|
589
|
$ctx->release; |
31
|
2
|
|
|
|
|
69
|
return; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
__END__ |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=pod |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=encoding UTF-8 |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 NAME |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Log::Log4perl::Appender::TAP - Append to TAP output |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 VERSION |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
version 0.05 |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 SYNOPSIS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
use Test2::V0; |
53
|
|
|
|
|
|
|
use Log::Log4perl; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
LOG::Log4perl::init(\<<CONF); |
56
|
|
|
|
|
|
|
log4perl.rootLogger=ERROR, TAP |
57
|
|
|
|
|
|
|
log4perl.appender.TAP=Log::Log4perl::Appender::TAP |
58
|
|
|
|
|
|
|
log4perl.appender.TAP.method=diag |
59
|
|
|
|
|
|
|
log4perl.appender.TAP=layout=PatternLayout |
60
|
|
|
|
|
|
|
log4perl.appender.TAP=layout.ConversionPattern="[%rms] %m%n" |
61
|
|
|
|
|
|
|
CONF |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
DEBUG "this message doesn't see the light of day"; |
64
|
|
|
|
|
|
|
ERROR "This gets logged to TAP using diag"; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 DESCRIPTION |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This very simple L<Log::Log4perl> appender sends log output via L<Test2::API> to TAP |
69
|
|
|
|
|
|
|
(or any other format supported by L<Test2::API>). It also works with |
70
|
|
|
|
|
|
|
L<Test::Builder> and L<Test::More> so long as you have L<Test2::API> |
71
|
|
|
|
|
|
|
installed. It only takes one special argument, the method, which can |
72
|
|
|
|
|
|
|
be either C<diag> or C<note>. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 SEE ALSO |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=over 4 |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item L<Log::Log4perl> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Main module documentation for C<Log4perl>. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item L<Log::Dispatch::TAP> |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Similar module but for L<Log::Dispatch> instead of C<Log4perl>. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=back |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 AUTHOR |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Graham Ollis <plicease@cpan.org> |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This software is copyright (c) 2017-2022 by Graham Ollis. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
97
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |