line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::Dispatch::TAP; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Log to TAP output |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
358705
|
use v5.14; |
|
1
|
|
|
|
|
7
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use Params::ValidationCompiler qw/ validation_for /; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
9
|
1
|
|
|
1
|
|
628
|
use Types::Standard qw/ Enum /; |
|
1
|
|
|
|
|
75833
|
|
|
1
|
|
|
|
|
7
|
|
10
|
1
|
|
|
1
|
|
775
|
use Test2::API qw/ context /; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
57
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
7
|
use base qw/ Log::Dispatch::Output /; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
509
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
36291
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = 'v0.2.0'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
2
|
|
|
2
|
0
|
5217
|
my $proto = shift; |
21
|
2
|
|
33
|
|
|
14
|
my $class = ref $proto || $proto; |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
7
|
state $validator = validation_for( |
24
|
|
|
|
|
|
|
params => { |
25
|
|
|
|
|
|
|
method => { |
26
|
|
|
|
|
|
|
type => Enum[qw/ note diag /], |
27
|
|
|
|
|
|
|
default => 'note', |
28
|
|
|
|
|
|
|
}, |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
slurpy => 1, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
4927
|
my %p = $validator->(@_); |
34
|
2
|
|
|
|
|
122
|
my $self = bless { method => $p{method} }, $class; |
35
|
2
|
|
|
|
|
17
|
$self->_basic_init(%p); |
36
|
2
|
|
|
|
|
199
|
return $self; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub log_message { |
41
|
2
|
|
|
2
|
0
|
676
|
my $self = shift; |
42
|
2
|
|
|
|
|
7
|
my %p = @_; |
43
|
2
|
|
|
|
|
7
|
my $ctx = context(); |
44
|
2
|
|
|
|
|
198
|
my $method = $ctx->can( $self->{method} ); |
45
|
2
|
|
|
|
|
7
|
$ctx->$method( $p{message} ); |
46
|
2
|
|
|
|
|
539
|
$ctx->release; |
47
|
2
|
|
|
|
|
51
|
return; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=pod |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=encoding UTF-8 |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 NAME |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Log::Dispatch::TAP - Log to TAP output |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 VERSION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
version v0.2.0 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 SYNOPSIS |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
use Log::Dispatch; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $logger = Log::Dispatch->new( |
72
|
|
|
|
|
|
|
outputs => [ |
73
|
|
|
|
|
|
|
[ |
74
|
|
|
|
|
|
|
'TAP', |
75
|
|
|
|
|
|
|
method => 'note', |
76
|
|
|
|
|
|
|
min_level => 'debug', |
77
|
|
|
|
|
|
|
] |
78
|
|
|
|
|
|
|
); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 DESCRIPTION |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This module provides a L<Log::Dispatch> output sink for logging to |
83
|
|
|
|
|
|
|
L<Test::Simple> diagnostics. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
It is similar to L<Log::Dispatch::TestDiag>, except that it allows you |
86
|
|
|
|
|
|
|
to choose the logging method. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
The constructor takes the following parameter in addition to the |
91
|
|
|
|
|
|
|
standard parameters for L<Log::Dispatch::Output>. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 method |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This is the logging method, which is either C<note> or C<diag> |
96
|
|
|
|
|
|
|
(corresponding to those functions in L<Test::More>). |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=for Pod::Coverage log_message |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 SUPPORT FOR OLDER PERL VERSIONS |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Since v0.2.0, the this module requires Perl v5.14 or later. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Future releases may only support Perl versions released in the last ten years. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
If you need this module on Perl v5.10, please use one of the v0.1.x |
107
|
|
|
|
|
|
|
versions of this module. Significant bug or security fixes may be |
108
|
|
|
|
|
|
|
backported to those versions. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 SEE ALSO |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
L<Log::Log4perl::Appender::TAP> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
L<Log::Dispatch::TestDiag> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 SOURCE |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
The development version is on github at L<https://github.com/robrwo/Log-Dispatch-TAP> |
119
|
|
|
|
|
|
|
and may be cloned from L<git://github.com/robrwo/Log-Dispatch-TAP.git> |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 BUGS |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website |
124
|
|
|
|
|
|
|
L<https://github.com/robrwo/Log-Dispatch-TAP/issues> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
127
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
128
|
|
|
|
|
|
|
feature. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 AUTHOR |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Robert Rothenberg <rrwo@cpan.org> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Some of the code was adapted from L<Log::Log4perl::Appender::TAP> |
135
|
|
|
|
|
|
|
and L<Log::Dispatch::TestDiag>. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
This software is Copyright (c) 2020-2023 by Robert Rothenberg. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
This is free software, licensed under: |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=cut |