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