line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::Dispatch::Handle; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1818
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
77
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
83
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '2.71'; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
14
|
use Log::Dispatch::Types; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
14
|
|
9
|
2
|
|
|
2
|
|
56901
|
use Params::ValidationCompiler qw( validation_for ); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
99
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
13
|
use base qw( Log::Dispatch::Output ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
667
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
{ |
14
|
|
|
|
|
|
|
my $validator = validation_for( |
15
|
|
|
|
|
|
|
params => { handle => { type => t('CanPrint') } }, |
16
|
|
|
|
|
|
|
slurpy => 1, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
1
|
|
|
1
|
0
|
16
|
my $class = shift; |
21
|
1
|
|
|
|
|
26
|
my %p = $validator->(@_); |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
78
|
my $self = bless { handle => delete $p{handle} }, $class; |
24
|
1
|
|
|
|
|
10
|
$self->_basic_init(%p); |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
8
|
return $self; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub log_message { |
31
|
1
|
|
|
1
|
0
|
4
|
my $self = shift; |
32
|
1
|
|
|
|
|
4
|
my %p = @_; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$self->{handle}->print( $p{message} ) |
35
|
1
|
50
|
|
|
|
116
|
or die "Cannot write to handle: $!"; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# ABSTRACT: Object for logging to IO::Handle classes |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=pod |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=encoding UTF-8 |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 NAME |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Log::Dispatch::Handle - Object for logging to IO::Handle classes |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 VERSION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
version 2.71 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 SYNOPSIS |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
use Log::Dispatch; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $log = Log::Dispatch->new( |
61
|
|
|
|
|
|
|
outputs => [ |
62
|
|
|
|
|
|
|
[ |
63
|
|
|
|
|
|
|
'Handle', |
64
|
|
|
|
|
|
|
min_level => 'emerg', |
65
|
|
|
|
|
|
|
handle => $io_socket_object, |
66
|
|
|
|
|
|
|
], |
67
|
|
|
|
|
|
|
] |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
$log->emerg('I am the Lizard King!'); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 DESCRIPTION |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This module supplies a very simple object for logging to some sort of handle |
75
|
|
|
|
|
|
|
object. Basically, anything that implements a C<print()> method can be passed |
76
|
|
|
|
|
|
|
the object constructor and it should work. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=for Pod::Coverage new log_message |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
The constructor takes the following parameters in addition to the standard |
83
|
|
|
|
|
|
|
parameters documented in L<Log::Dispatch::Output>: |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=over 4 |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item * handle ($) |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
The handle object. This object must implement a C<print()> method. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=back |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 SUPPORT |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Bugs may be submitted at L<https://github.com/houseabsolute/Log-Dispatch/issues>. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 SOURCE |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
The source code repository for Log-Dispatch can be found at L<https://github.com/houseabsolute/Log-Dispatch>. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 AUTHOR |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This software is Copyright (c) 2023 by Dave Rolsky. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This is free software, licensed under: |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
The full text of the license can be found in the |
114
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |