line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CTK::Plugin::Log; |
2
|
2
|
|
|
2
|
|
15
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
61
|
|
3
|
2
|
|
|
2
|
|
9
|
use utf8; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
13
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=encoding utf-8 |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
CTK::Plugin::Log - Logger plugin |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 1.01 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use CTK; |
18
|
|
|
|
|
|
|
use CTK::Log qw/:constants/; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $ctk = CTK->new( |
21
|
|
|
|
|
|
|
plugins => "log", |
22
|
|
|
|
|
|
|
ident => "myapp", |
23
|
|
|
|
|
|
|
logfile => "test.log", |
24
|
|
|
|
|
|
|
logger_init => 1, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
print $ctk->log_debug("Logger say: %s", "foo"); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Logger plugin |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=over 8 |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=item B |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Specifies ident string for each log-record |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
See L |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item B |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Specifies log file |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
See L |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item B |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Really not used |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item B |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Flag enabling the logger autoloading |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
If flag is enabled, then the data from the configuration will be used |
55
|
|
|
|
|
|
|
for logger initialization |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=back |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 METHODS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=over 8 |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item B |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
die $ctk->logger->error unless $ctk->logger->status; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Returns logger-object |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item B |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
$ctk->logger_init( ... ); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Init logger. See L |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item B |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
$ctk->log_debug( "format %s", "value", ... ); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Sends debug message in sprintf fromat to log. See L |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item B |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
$ctk->log_info( "format %s", "value", ... ); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Sends informational message in sprintf fromat to log. See L |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item B |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
$ctk->log_notice( "format %s", "value", ... ); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Sends notice message in sprintf fromat to log. See L |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item B, B |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
$ctk->log_warning( "format %s", "value", ... ); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Sends warning message in sprintf fromat to log. See L |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item B |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
$ctk->log_error( "format %s", "value", ... ); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Sends error message in sprintf fromat to log. See L |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item B |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
$ctk->log_crit( "format %s", "value", ... ); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Sends critical message in sprintf fromat to log. See L |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item B |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
$ctk->log_alert( "format %s", "value", ... ); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Sends alert message in sprintf fromat to log. See L |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item B |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
$ctk->log_emerg( "format %s", "value", ... ); |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Sends emergency message in sprintf fromat to log. See L |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item B |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
$ctk->log_fatal( "format %s", "value", ... ); |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Sends fatal message in sprintf fromat to log. See L |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item B, B |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
$ctk->log_except( "format %s", "value", ... ); |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Sends exception message in sprintf fromat to log. See L |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=back |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 init |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Initializer method. Internal use only |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 HISTORY |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
See C file |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
L, L, L |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 TO DO |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
See C file |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 BUGS |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
* none noted |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 SEE ALSO |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
L, L, L |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 AUTHOR |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Serż Minus (Sergey Lepenkov) L Eabalama@cpan.orgE |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 COPYRIGHT |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Copyright (C) 1998-2022 D&D Corporation. All Rights Reserved |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 LICENSE |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
173
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
See C file and L |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=cut |
178
|
|
|
|
|
|
|
|
179
|
2
|
|
|
2
|
|
85
|
use vars qw/ $VERSION /; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
97
|
|
180
|
|
|
|
|
|
|
$VERSION = '1.01'; |
181
|
|
|
|
|
|
|
|
182
|
2
|
|
|
2
|
|
9
|
use base qw/CTK::Plugin/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
255
|
|
183
|
|
|
|
|
|
|
|
184
|
2
|
|
|
2
|
|
816
|
use CTK::Log; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
1451
|
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub init { |
187
|
2
|
|
|
2
|
1
|
4
|
my $self = shift; # It is CTK object! |
188
|
2
|
|
|
|
|
6
|
$self->{logger} = undef; |
189
|
2
|
|
|
|
|
6
|
return 1; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
__PACKAGE__->register_method( |
193
|
|
|
|
|
|
|
method => "logger", |
194
|
0
|
|
|
0
|
|
0
|
callback => sub { shift->{logger} }); |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
__PACKAGE__->register_method( |
197
|
|
|
|
|
|
|
method => "logger_init", |
198
|
|
|
|
|
|
|
callback => sub { |
199
|
1
|
|
|
1
|
|
4
|
my $self = shift; |
200
|
1
|
|
|
|
|
6
|
my %args = @_; |
201
|
1
|
|
0
|
|
|
5
|
$args{ident} //= $self->{ident} // $self->project; # From args or object or is project |
|
|
|
33
|
|
|
|
|
202
|
1
|
|
|
|
|
12
|
return $self->{logger} = CTK::Log->new(%args); |
203
|
|
|
|
|
|
|
}); |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
__PACKAGE__->register_method( |
206
|
|
|
|
|
|
|
method => "log_debug", |
207
|
|
|
|
|
|
|
callback => sub { |
208
|
0
|
|
|
0
|
|
|
my $self = shift; |
209
|
0
|
|
0
|
|
|
|
my $logger = $self->{logger} || return 0; |
210
|
0
|
|
|
|
|
|
return $logger->log_debug(@_); |
211
|
|
|
|
|
|
|
}); |
212
|
|
|
|
|
|
|
__PACKAGE__->register_method( |
213
|
|
|
|
|
|
|
method => "log_info", |
214
|
|
|
|
|
|
|
callback => sub { |
215
|
0
|
|
|
0
|
|
|
my $self = shift; |
216
|
0
|
|
0
|
|
|
|
my $logger = $self->{logger} || return 0; |
217
|
0
|
|
|
|
|
|
return $logger->log_info(@_); |
218
|
|
|
|
|
|
|
}); |
219
|
|
|
|
|
|
|
__PACKAGE__->register_method( |
220
|
|
|
|
|
|
|
method => "log_notice", |
221
|
|
|
|
|
|
|
callback => sub { |
222
|
0
|
|
|
0
|
|
|
my $self = shift; |
223
|
0
|
|
0
|
|
|
|
my $logger = $self->{logger} || return 0; |
224
|
0
|
|
|
|
|
|
return $logger->log_notice(@_); |
225
|
|
|
|
|
|
|
}); |
226
|
|
|
|
|
|
|
__PACKAGE__->register_method( |
227
|
|
|
|
|
|
|
method => "log_warning", |
228
|
|
|
|
|
|
|
callback => sub { |
229
|
0
|
|
|
0
|
|
|
my $self = shift; |
230
|
0
|
|
0
|
|
|
|
my $logger = $self->{logger} || return 0; |
231
|
0
|
|
|
|
|
|
return $logger->log_warning(@_); |
232
|
|
|
|
|
|
|
}); |
233
|
|
|
|
|
|
|
__PACKAGE__->register_method( |
234
|
|
|
|
|
|
|
method => "log_warn", |
235
|
|
|
|
|
|
|
callback => sub { |
236
|
0
|
|
|
0
|
|
|
my $self = shift; |
237
|
0
|
|
0
|
|
|
|
my $logger = $self->{logger} || return 0; |
238
|
0
|
|
|
|
|
|
return $logger->log_warn(@_); |
239
|
|
|
|
|
|
|
}); |
240
|
|
|
|
|
|
|
__PACKAGE__->register_method( |
241
|
|
|
|
|
|
|
method => "log_error", |
242
|
|
|
|
|
|
|
callback => sub { |
243
|
0
|
|
|
0
|
|
|
my $self = shift; |
244
|
0
|
|
0
|
|
|
|
my $logger = $self->{logger} || return 0; |
245
|
0
|
|
|
|
|
|
return $logger->log_error(@_); |
246
|
|
|
|
|
|
|
}); |
247
|
|
|
|
|
|
|
__PACKAGE__->register_method( |
248
|
|
|
|
|
|
|
method => "log_crit", |
249
|
|
|
|
|
|
|
callback => sub { |
250
|
0
|
|
|
0
|
|
|
my $self = shift; |
251
|
0
|
|
0
|
|
|
|
my $logger = $self->{logger} || return 0; |
252
|
0
|
|
|
|
|
|
return $logger->log_crit(@_); |
253
|
|
|
|
|
|
|
}); |
254
|
|
|
|
|
|
|
__PACKAGE__->register_method( |
255
|
|
|
|
|
|
|
method => "log_alert", |
256
|
|
|
|
|
|
|
callback => sub { |
257
|
0
|
|
|
0
|
|
|
my $self = shift; |
258
|
0
|
|
0
|
|
|
|
my $logger = $self->{logger} || return 0; |
259
|
0
|
|
|
|
|
|
return $logger->log_alert(@_); |
260
|
|
|
|
|
|
|
}); |
261
|
|
|
|
|
|
|
__PACKAGE__->register_method( |
262
|
|
|
|
|
|
|
method => "log_emerg", |
263
|
|
|
|
|
|
|
callback => sub { |
264
|
0
|
|
|
0
|
|
|
my $self = shift; |
265
|
0
|
|
0
|
|
|
|
my $logger = $self->{logger} || return 0; |
266
|
0
|
|
|
|
|
|
return $logger->log_emerg(@_); |
267
|
|
|
|
|
|
|
}); |
268
|
|
|
|
|
|
|
__PACKAGE__->register_method( |
269
|
|
|
|
|
|
|
method => "log_fatal", |
270
|
|
|
|
|
|
|
callback => sub { |
271
|
0
|
|
|
0
|
|
|
my $self = shift; |
272
|
0
|
|
0
|
|
|
|
my $logger = $self->{logger} || return 0; |
273
|
0
|
|
|
|
|
|
return $logger->log_fatal(@_); |
274
|
|
|
|
|
|
|
}); |
275
|
|
|
|
|
|
|
__PACKAGE__->register_method( |
276
|
|
|
|
|
|
|
method => "log_except", |
277
|
|
|
|
|
|
|
callback => sub { |
278
|
0
|
|
|
0
|
|
|
my $self = shift; |
279
|
0
|
|
0
|
|
|
|
my $logger = $self->{logger} || return 0; |
280
|
0
|
|
|
|
|
|
return $logger->log_except(@_); |
281
|
|
|
|
|
|
|
}); |
282
|
|
|
|
|
|
|
__PACKAGE__->register_method( |
283
|
|
|
|
|
|
|
method => "log_exception", |
284
|
|
|
|
|
|
|
callback => sub { |
285
|
0
|
|
|
0
|
|
|
my $self = shift; |
286
|
0
|
|
0
|
|
|
|
my $logger = $self->{logger} || return 0; |
287
|
0
|
|
|
|
|
|
return $logger->log_exception(@_); |
288
|
|
|
|
|
|
|
}); |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
1; |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
__END__ |