line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
255227
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
2
|
1
|
|
|
1
|
|
11
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
49
|
|
3
|
|
|
|
|
|
|
package Log::Dispatch::Array 1.004; |
4
|
1
|
|
|
1
|
|
6
|
use parent qw(Log::Dispatch::Output); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
7
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: log events to an array (reference) |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
8
|
|
|
|
|
|
|
#pod |
9
|
|
|
|
|
|
|
#pod use Log::Dispatch; |
10
|
|
|
|
|
|
|
#pod use Log::Dispatch::Array; |
11
|
|
|
|
|
|
|
#pod |
12
|
|
|
|
|
|
|
#pod my $log = Log::Dispatch->new; |
13
|
|
|
|
|
|
|
#pod |
14
|
|
|
|
|
|
|
#pod my $target = []; |
15
|
|
|
|
|
|
|
#pod |
16
|
|
|
|
|
|
|
#pod $log->add(Log::Dispatch::Array->new( |
17
|
|
|
|
|
|
|
#pod name => 'text_table', |
18
|
|
|
|
|
|
|
#pod min_level => 'debug', |
19
|
|
|
|
|
|
|
#pod array => $target, |
20
|
|
|
|
|
|
|
#pod )); |
21
|
|
|
|
|
|
|
#pod |
22
|
|
|
|
|
|
|
#pod $log->warn($_) for @events; |
23
|
|
|
|
|
|
|
#pod |
24
|
|
|
|
|
|
|
#pod # now $target refers to an array of events |
25
|
|
|
|
|
|
|
#pod |
26
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
27
|
|
|
|
|
|
|
#pod |
28
|
|
|
|
|
|
|
#pod This provides a Log::Dispatch log output system that appends logged events to |
29
|
|
|
|
|
|
|
#pod an array reference. This is probably only useful for testing the logging of |
30
|
|
|
|
|
|
|
#pod your code. |
31
|
|
|
|
|
|
|
#pod |
32
|
|
|
|
|
|
|
#pod =method new |
33
|
|
|
|
|
|
|
#pod |
34
|
|
|
|
|
|
|
#pod my $table_log = Log::Dispatch::Array->new(\%arg); |
35
|
|
|
|
|
|
|
#pod |
36
|
|
|
|
|
|
|
#pod This method constructs a new Log::Dispatch::Array output object. Valid |
37
|
|
|
|
|
|
|
#pod arguments are: |
38
|
|
|
|
|
|
|
#pod |
39
|
|
|
|
|
|
|
#pod array - a reference to an array to append to; defaults to an attr on |
40
|
|
|
|
|
|
|
#pod $table_log |
41
|
|
|
|
|
|
|
#pod |
42
|
|
|
|
|
|
|
#pod =cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub new { |
45
|
1
|
|
|
1
|
1
|
942
|
my ($class, %arg) = @_; |
46
|
1
|
|
50
|
|
|
24
|
$arg{array} ||= []; |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
3
|
my $self = { array => $arg{array} }; |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
|
|
3
|
bless $self => $class; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# this is our duty as a well-behaved Log::Dispatch plugin |
53
|
1
|
|
|
|
|
9
|
$self->_basic_init(%arg); |
54
|
|
|
|
|
|
|
|
55
|
1
|
|
|
|
|
101
|
return $self; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
#pod =method array |
59
|
|
|
|
|
|
|
#pod |
60
|
|
|
|
|
|
|
#pod This method returns a reference to the array to which logging is being |
61
|
|
|
|
|
|
|
#pod performed. |
62
|
|
|
|
|
|
|
#pod |
63
|
|
|
|
|
|
|
#pod =cut |
64
|
|
|
|
|
|
|
|
65
|
3
|
|
|
3
|
1
|
24
|
sub array { $_[0]->{array} } |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
#pod =method log_message |
68
|
|
|
|
|
|
|
#pod |
69
|
|
|
|
|
|
|
#pod This is the method which performs the actual logging, as detailed by |
70
|
|
|
|
|
|
|
#pod Log::Dispatch::Output. |
71
|
|
|
|
|
|
|
#pod |
72
|
|
|
|
|
|
|
#pod =cut |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub log_message { |
75
|
2
|
|
|
2
|
1
|
952
|
my ($self, %p) = @_; |
76
|
2
|
|
|
|
|
4
|
push @{ $self->array }, { %p }; |
|
2
|
|
|
|
|
9
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=pod |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=encoding UTF-8 |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 NAME |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Log::Dispatch::Array - log events to an array (reference) |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 VERSION |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
version 1.004 |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 SYNOPSIS |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
use Log::Dispatch; |
98
|
|
|
|
|
|
|
use Log::Dispatch::Array; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
my $log = Log::Dispatch->new; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my $target = []; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
$log->add(Log::Dispatch::Array->new( |
105
|
|
|
|
|
|
|
name => 'text_table', |
106
|
|
|
|
|
|
|
min_level => 'debug', |
107
|
|
|
|
|
|
|
array => $target, |
108
|
|
|
|
|
|
|
)); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
$log->warn($_) for @events; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# now $target refers to an array of events |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 DESCRIPTION |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This provides a Log::Dispatch log output system that appends logged events to |
117
|
|
|
|
|
|
|
an array reference. This is probably only useful for testing the logging of |
118
|
|
|
|
|
|
|
your code. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 METHODS |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 new |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
my $table_log = Log::Dispatch::Array->new(\%arg); |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This method constructs a new Log::Dispatch::Array output object. Valid |
127
|
|
|
|
|
|
|
arguments are: |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
array - a reference to an array to append to; defaults to an attr on |
130
|
|
|
|
|
|
|
$table_log |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 array |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This method returns a reference to the array to which logging is being |
135
|
|
|
|
|
|
|
performed. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 log_message |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
This is the method which performs the actual logging, as detailed by |
140
|
|
|
|
|
|
|
Log::Dispatch::Output. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 AUTHOR |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Ricardo SIGNES <cpan@semiotic.systems> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 CONTRIBUTOR |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=for stopwords Ricardo Signes |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Ricardo Signes <rjbs@semiotic.systems> |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This software is copyright (c) 2008 by Ricardo SIGNES. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
157
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |