line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
################################################## |
2
|
|
|
|
|
|
|
################################################## |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use 5.006; |
5
|
70
|
|
|
70
|
|
1199
|
use strict; |
|
70
|
|
|
|
|
259
|
|
6
|
70
|
|
|
70
|
|
371
|
use warnings; |
|
70
|
|
|
|
|
191
|
|
|
70
|
|
|
|
|
1446
|
|
7
|
70
|
|
|
70
|
|
356
|
|
|
70
|
|
|
|
|
152
|
|
|
70
|
|
|
|
|
1950
|
|
8
|
|
|
|
|
|
|
use Log::Log4perl; |
9
|
70
|
|
|
70
|
|
363
|
use Log::Log4perl::Level; |
|
70
|
|
|
|
|
160
|
|
|
70
|
|
|
|
|
2114
|
|
10
|
70
|
|
|
70
|
|
31204
|
use Log::Log4perl::Layout; |
|
70
|
|
|
|
|
175
|
|
|
70
|
|
|
|
|
283
|
|
11
|
70
|
|
|
70
|
|
30832
|
use Log::Log4perl::Appender; |
|
70
|
|
|
|
|
199
|
|
|
70
|
|
|
|
|
1962
|
|
12
|
70
|
|
|
70
|
|
34351
|
use Log::Log4perl::Appender::String; |
|
70
|
|
|
|
|
194
|
|
|
70
|
|
|
|
|
2126
|
|
13
|
70
|
|
|
70
|
|
41272
|
use Log::Log4perl::Filter; |
|
70
|
|
|
|
|
211
|
|
|
70
|
|
|
|
|
2400
|
|
14
|
70
|
|
|
70
|
|
31276
|
use Carp; |
|
70
|
|
|
|
|
705
|
|
|
70
|
|
|
|
|
2817
|
|
15
|
70
|
|
|
70
|
|
510
|
|
|
70
|
|
|
|
|
165
|
|
|
70
|
|
|
|
|
5527
|
|
16
|
|
|
|
|
|
|
$Carp::Internal{"Log::Log4perl"}++; |
17
|
|
|
|
|
|
|
$Carp::Internal{"Log::Log4perl::Logger"}++; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use constant _INTERNAL_DEBUG => 0; |
20
|
70
|
|
|
70
|
|
5084
|
|
|
70
|
|
|
|
|
312
|
|
|
70
|
|
|
|
|
251225
|
|
21
|
|
|
|
|
|
|
# Initialization |
22
|
|
|
|
|
|
|
our $ROOT_LOGGER; |
23
|
|
|
|
|
|
|
our $LOGGERS_BY_NAME = {}; |
24
|
|
|
|
|
|
|
our %APPENDER_BY_NAME = (); |
25
|
|
|
|
|
|
|
our $INITIALIZED = 0; |
26
|
|
|
|
|
|
|
our $NON_INIT_WARNED; |
27
|
|
|
|
|
|
|
our $DIE_DEBUG = 0; |
28
|
|
|
|
|
|
|
our $DIE_DEBUG_BUFFER = ""; |
29
|
|
|
|
|
|
|
# Define the default appender that's used for formatting |
30
|
|
|
|
|
|
|
# warn/die/croak etc. messages. |
31
|
|
|
|
|
|
|
our $STRING_APP_NAME = "_l4p_warn"; |
32
|
|
|
|
|
|
|
our $STRING_APP = Log::Log4perl::Appender->new( |
33
|
|
|
|
|
|
|
"Log::Log4perl::Appender::String", |
34
|
|
|
|
|
|
|
name => $STRING_APP_NAME); |
35
|
|
|
|
|
|
|
$STRING_APP->layout(Log::Log4perl::Layout::PatternLayout->new("%m")); |
36
|
|
|
|
|
|
|
our $STRING_APP_CODEREF = generate_coderef([[$STRING_APP_NAME, $STRING_APP]]); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
__PACKAGE__->reset(); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
########################################### |
41
|
|
|
|
|
|
|
########################################### |
42
|
|
|
|
|
|
|
my($logger, @message) = @_; |
43
|
|
|
|
|
|
|
|
44
|
50
|
|
|
50
|
0
|
146
|
$STRING_APP->string(""); |
45
|
|
|
|
|
|
|
$STRING_APP_CODEREF->($logger, |
46
|
50
|
|
|
|
|
301
|
@message, |
47
|
50
|
|
|
|
|
155
|
Log::Log4perl::Level::to_level($ALL)); |
48
|
|
|
|
|
|
|
return $STRING_APP->string(); |
49
|
|
|
|
|
|
|
} |
50
|
50
|
|
|
|
|
226
|
|
51
|
|
|
|
|
|
|
################################################## |
52
|
|
|
|
|
|
|
################################################## |
53
|
|
|
|
|
|
|
# warn "Logger cleanup"; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Nuke all convenience loggers to avoid them causing cleanup to |
56
|
|
|
|
|
|
|
# be delayed until global destruction. Problem is that something like |
57
|
|
|
|
|
|
|
# *{"DEBUG"} = sub { $logger->debug }; |
58
|
|
|
|
|
|
|
# ties up a reference to $logger until global destruction, so we |
59
|
|
|
|
|
|
|
# need to clean up all :easy shortcuts, hence freeing the last |
60
|
|
|
|
|
|
|
# logger references, to then rely on the garbage collector for cleaning |
61
|
|
|
|
|
|
|
# up the loggers. |
62
|
|
|
|
|
|
|
Log::Log4perl->easy_closure_global_cleanup(); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Delete all loggers |
65
|
72
|
|
|
72
|
0
|
736
|
$LOGGERS_BY_NAME = {}; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Delete the root logger |
68
|
72
|
|
|
|
|
424
|
undef $ROOT_LOGGER; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Delete all appenders |
71
|
72
|
|
|
|
|
340
|
%APPENDER_BY_NAME = (); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
undef $INITIALIZED; |
74
|
72
|
|
|
|
|
401
|
} |
75
|
|
|
|
|
|
|
|
76
|
72
|
|
|
|
|
2058
|
################################################## |
77
|
|
|
|
|
|
|
################################################## |
78
|
|
|
|
|
|
|
CORE::warn "Destroying logger $_[0] ($_[0]->{category})" |
79
|
|
|
|
|
|
|
if $Log::Log4perl::CHATTY_DESTROY_METHODS; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
155
|
50
|
|
155
|
|
2556
|
################################################## |
83
|
|
|
|
|
|
|
################################################## |
84
|
|
|
|
|
|
|
$ROOT_LOGGER = __PACKAGE__->_new("", $OFF); |
85
|
|
|
|
|
|
|
# $LOGGERS_BY_NAME = {}; #leave this alone, it's used by |
86
|
|
|
|
|
|
|
#reset_all_output_methods when |
87
|
|
|
|
|
|
|
#the config changes |
88
|
|
|
|
|
|
|
|
89
|
295
|
|
|
295
|
0
|
959
|
%APPENDER_BY_NAME = (); |
90
|
|
|
|
|
|
|
undef $INITIALIZED; |
91
|
|
|
|
|
|
|
undef $NON_INIT_WARNED; |
92
|
|
|
|
|
|
|
Log::Log4perl::Appender::reset(); |
93
|
|
|
|
|
|
|
|
94
|
295
|
|
|
|
|
813
|
#clear out all the existing appenders |
95
|
295
|
|
|
|
|
623
|
foreach my $logger (values %$LOGGERS_BY_NAME){ |
96
|
295
|
|
|
|
|
553
|
$logger->{appender_names} = []; |
97
|
295
|
|
|
|
|
1175
|
|
98
|
|
|
|
|
|
|
#this next bit deals with an init_and_watch case where a category |
99
|
|
|
|
|
|
|
#is deleted from the config file, we need to zero out the existing |
100
|
295
|
|
|
|
|
963
|
#loggers so ones not in the config file not continue with their old |
101
|
567
|
|
|
|
|
1461
|
#behavior --kg |
102
|
|
|
|
|
|
|
next if $logger eq $ROOT_LOGGER; |
103
|
|
|
|
|
|
|
$logger->{level} = undef; |
104
|
|
|
|
|
|
|
$logger->level(); #set it from the hierarchy |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
567
|
100
|
|
|
|
2058
|
# Clear all filters |
108
|
272
|
|
|
|
|
513
|
Log::Log4perl::Filter::reset(); |
109
|
272
|
|
|
|
|
665
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
################################################## |
112
|
|
|
|
|
|
|
################################################## |
113
|
295
|
|
|
|
|
1090
|
my($class, $category, $level) = @_; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
print("_new: $class/$category/", defined $level ? $level : "undef", |
116
|
|
|
|
|
|
|
"\n") if _INTERNAL_DEBUG; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
die "usage: __PACKAGE__->_new(category)" unless |
119
|
569
|
|
|
569
|
|
1403
|
defined $category; |
120
|
|
|
|
|
|
|
|
121
|
569
|
|
|
|
|
823
|
$category =~ s/::/./g; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# Have we created it previously? |
124
|
569
|
50
|
|
|
|
1488
|
if(exists $LOGGERS_BY_NAME->{$category}) { |
125
|
|
|
|
|
|
|
print "_new: exists already\n" if _INTERNAL_DEBUG; |
126
|
|
|
|
|
|
|
return $LOGGERS_BY_NAME->{$category}; |
127
|
569
|
|
|
|
|
1382
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
my $self = { |
130
|
569
|
100
|
|
|
|
1721
|
category => $category, |
131
|
384
|
|
|
|
|
575
|
num_appenders => 0, |
132
|
384
|
|
|
|
|
1077
|
additivity => 1, |
133
|
|
|
|
|
|
|
level => $level, |
134
|
|
|
|
|
|
|
layout => undef, |
135
|
185
|
|
|
|
|
938
|
}; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
bless $self, $class; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
$level ||= $self->level(); |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# Save it in global structure |
142
|
|
|
|
|
|
|
$LOGGERS_BY_NAME->{$category} = $self; |
143
|
185
|
|
|
|
|
466
|
|
144
|
|
|
|
|
|
|
$self->set_output_methods; |
145
|
185
|
|
100
|
|
|
837
|
|
146
|
|
|
|
|
|
|
print("Created logger $self ($category)\n") if _INTERNAL_DEBUG; |
147
|
|
|
|
|
|
|
|
148
|
185
|
|
|
|
|
491
|
return $self; |
149
|
|
|
|
|
|
|
} |
150
|
185
|
|
|
|
|
674
|
|
151
|
|
|
|
|
|
|
################################################## |
152
|
185
|
|
|
|
|
372
|
################################################## |
153
|
|
|
|
|
|
|
my ($self) = @_; |
154
|
185
|
|
|
|
|
438
|
|
155
|
|
|
|
|
|
|
return $self->{ category }; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
################################################## |
159
|
|
|
|
|
|
|
################################################## |
160
|
1
|
|
|
1
|
0
|
6
|
print "reset_all_output_methods: \n" if _INTERNAL_DEBUG; |
161
|
|
|
|
|
|
|
|
162
|
1
|
|
|
|
|
4
|
foreach my $loggername ( keys %$LOGGERS_BY_NAME){ |
163
|
|
|
|
|
|
|
$LOGGERS_BY_NAME->{$loggername}->set_output_methods; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
$ROOT_LOGGER->set_output_methods; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
251
|
|
|
251
|
0
|
383
|
################################################## |
169
|
|
|
|
|
|
|
# Here's a big performance increase. Instead of having the logger |
170
|
251
|
|
|
|
|
869
|
# calculate whether to log and whom to log to every time log() is called, |
171
|
738
|
|
|
|
|
1759
|
# we calculate it once when the logger is created, and recalculate |
172
|
|
|
|
|
|
|
# it if the config information ever changes. |
173
|
251
|
|
|
|
|
736
|
# |
174
|
|
|
|
|
|
|
################################################## |
175
|
|
|
|
|
|
|
my ($self) = @_; |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
my (@appenders, %seen); |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
my ($level) = $self->level(); |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
print "set_output_methods: $self->{category}/$level\n" if _INTERNAL_DEBUG; |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
#collect the appenders in effect for this category |
184
|
1183
|
|
|
1183
|
0
|
2064
|
|
185
|
|
|
|
|
|
|
for(my $logger = $self; $logger; $logger = parent_logger($logger)) { |
186
|
1183
|
|
|
|
|
1834
|
|
187
|
|
|
|
|
|
|
foreach my $appender_name (@{$logger->{appender_names}}){ |
188
|
1183
|
|
|
|
|
2391
|
|
189
|
|
|
|
|
|
|
#only one message per appender, (configurable) |
190
|
1183
|
|
|
|
|
1764
|
next if $seen{$appender_name} ++ && |
191
|
|
|
|
|
|
|
$Log::Log4perl::one_message_per_appender; |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
push (@appenders, |
194
|
1183
|
|
|
|
|
2916
|
[$appender_name, |
195
|
|
|
|
|
|
|
$APPENDER_BY_NAME{$appender_name}, |
196
|
1870
|
|
|
|
|
2563
|
] |
|
1870
|
|
|
|
|
3964
|
|
197
|
|
|
|
|
|
|
); |
198
|
|
|
|
|
|
|
} |
199
|
908
|
100
|
100
|
|
|
2449
|
last unless $logger->{additivity}; |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
#make a no-op coderef for inactive levels |
203
|
|
|
|
|
|
|
my $noop = generate_noop_coderef(); |
204
|
902
|
|
|
|
|
2526
|
|
205
|
|
|
|
|
|
|
#make a coderef |
206
|
|
|
|
|
|
|
my $coderef = (! @appenders ? $noop : &generate_coderef(\@appenders)); |
207
|
|
|
|
|
|
|
|
208
|
1870
|
100
|
|
|
|
4730
|
my %priority = %Log::Log4perl::Level::PRIORITY; #convenience and cvs |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
# changed to >= from <= as level ints were reversed |
211
|
|
|
|
|
|
|
foreach my $levelname (keys %priority){ |
212
|
1183
|
|
|
|
|
2299
|
if (Log::Log4perl::Level::isGreaterOrEqual($level, |
213
|
|
|
|
|
|
|
$priority{$levelname} |
214
|
|
|
|
|
|
|
)) { |
215
|
1183
|
100
|
|
|
|
9545
|
print " ($priority{$levelname} <= $level)\n" |
216
|
|
|
|
|
|
|
if _INTERNAL_DEBUG; |
217
|
1183
|
|
|
|
|
7265
|
$self->{$levelname} = $coderef; |
218
|
|
|
|
|
|
|
$self->{"is_$levelname"} = generate_is_xxx_coderef("1"); |
219
|
|
|
|
|
|
|
print "Setting is_$levelname to 1\n" if _INTERNAL_DEBUG; |
220
|
1183
|
|
|
|
|
3941
|
}else{ |
221
|
10518
|
100
|
|
|
|
21619
|
print " ($priority{$levelname} > $level)\n" if _INTERNAL_DEBUG; |
222
|
|
|
|
|
|
|
$self->{$levelname} = $noop; |
223
|
|
|
|
|
|
|
$self->{"is_$levelname"} = generate_is_xxx_coderef("0"); |
224
|
5041
|
|
|
|
|
6355
|
print "Setting is_$levelname to 0\n" if _INTERNAL_DEBUG; |
225
|
|
|
|
|
|
|
} |
226
|
5041
|
|
|
|
|
10869
|
|
227
|
5041
|
|
|
|
|
7998
|
print(" Setting [$self] $self->{category}.$levelname to ", |
228
|
5041
|
|
|
|
|
7757
|
($self->{$levelname} == $noop ? "NOOP" : |
229
|
|
|
|
|
|
|
("Coderef [$coderef]: " . scalar @appenders . " appenders")), |
230
|
5477
|
|
|
|
|
7012
|
"\n") if _INTERNAL_DEBUG; |
231
|
5477
|
|
|
|
|
8802
|
} |
232
|
5477
|
|
|
|
|
8357
|
} |
233
|
5477
|
|
|
|
|
8351
|
|
234
|
|
|
|
|
|
|
################################################## |
235
|
|
|
|
|
|
|
################################################## |
236
|
|
|
|
|
|
|
my $appenders = shift; |
237
|
10518
|
|
|
|
|
18303
|
|
238
|
|
|
|
|
|
|
print "generate_coderef: ", scalar @$appenders, |
239
|
|
|
|
|
|
|
" appenders\n" if _INTERNAL_DEBUG; |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
my $watch_check_code = generate_watch_code("logger", 1); |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
return sub { |
244
|
|
|
|
|
|
|
my $logger = shift; |
245
|
|
|
|
|
|
|
my $level = pop; |
246
|
786
|
|
|
786
|
0
|
1264
|
|
247
|
|
|
|
|
|
|
my $message; |
248
|
786
|
|
|
|
|
1052
|
my $appenders_fired = 0; |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
# Evaluate all parameters that need to be evaluated. Two kinds: |
251
|
786
|
|
|
|
|
1383
|
# |
252
|
|
|
|
|
|
|
# (1) It's a hash like { filter => "filtername", |
253
|
|
|
|
|
|
|
# value => "value" } |
254
|
499
|
|
|
499
|
|
903
|
# => filtername(value) |
255
|
499
|
|
|
|
|
816
|
# |
256
|
|
|
|
|
|
|
# (2) It's a code ref |
257
|
499
|
|
|
|
|
682
|
# => coderef() |
258
|
499
|
|
|
|
|
1677
|
# |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
$message = [map { ref $_ eq "HASH" && |
261
|
|
|
|
|
|
|
exists $_->{filter} && |
262
|
|
|
|
|
|
|
ref $_->{filter} eq 'CODE' ? |
263
|
|
|
|
|
|
|
$_->{filter}->($_->{value}) : |
264
|
|
|
|
|
|
|
ref $_ eq "CODE" ? |
265
|
|
|
|
|
|
|
$_->() : $_ |
266
|
|
|
|
|
|
|
} @_]; |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
print("coderef: $logger->{category}\n") if _INTERNAL_DEBUG; |
269
|
|
|
|
|
|
|
|
270
|
499
|
|
|
|
|
998
|
if(defined $Log::Log4perl::Config::WATCHER) { |
271
|
|
|
|
|
|
|
return unless $watch_check_code->($logger, @_, $level); |
272
|
|
|
|
|
|
|
} |
273
|
541
|
100
|
66
|
|
|
2963
|
|
|
|
100
|
|
|
|
|
|
274
|
|
|
|
|
|
|
foreach my $a (@$appenders) { #note the closure here |
275
|
|
|
|
|
|
|
my ($appender_name, $appender) = @$a; |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
print(" Sending message '<$message->[0]>' ($level) " . |
278
|
499
|
|
|
|
|
1070
|
"to $appender_name\n") if _INTERNAL_DEBUG; |
279
|
|
|
|
|
|
|
|
280
|
499
|
100
|
|
|
|
1188
|
$appender->log( |
281
|
20
|
100
|
|
|
|
63
|
#these get passed through to Log::Dispatch |
282
|
|
|
|
|
|
|
{ name => $appender_name, |
283
|
|
|
|
|
|
|
level => $Log::Log4perl::Level::L4P_TO_LD{ |
284
|
497
|
|
|
|
|
992
|
$level}, |
285
|
553
|
|
|
|
|
1159
|
message => $message, |
286
|
|
|
|
|
|
|
}, |
287
|
553
|
|
|
|
|
777
|
#these we need |
288
|
|
|
|
|
|
|
$logger->{category}, |
289
|
|
|
|
|
|
|
$level, |
290
|
|
|
|
|
|
|
) and $appenders_fired++; |
291
|
|
|
|
|
|
|
# Only counting it if it returns a true value. Otherwise |
292
|
|
|
|
|
|
|
# the appender threshold might have suppressed it after all. |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
} #end foreach appenders |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
return $appenders_fired; |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
}; #end coderef |
299
|
553
|
100
|
|
|
|
2944
|
} |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
################################################## |
302
|
|
|
|
|
|
|
################################################## |
303
|
|
|
|
|
|
|
my $watch_delay_code; |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
# This might seem crazy at first, but even in a Log4perl noop, we |
306
|
497
|
|
|
|
|
1473
|
# need to check if the configuration changed in a init_and_watch |
307
|
|
|
|
|
|
|
# situation. Why? Say, an application is running in a loop that |
308
|
786
|
|
|
|
|
3657
|
# constantly tries to issue debug() messages, but they're suppressed by |
309
|
|
|
|
|
|
|
# the current Log4perl configuration. If debug() (which is a noop |
310
|
|
|
|
|
|
|
# here) wasn't watching the configuration for changes, it would never |
311
|
|
|
|
|
|
|
# catch the case where someone bumps up the log level and expects |
312
|
|
|
|
|
|
|
# the application to pick it up and start logging debug() statements. |
313
|
|
|
|
|
|
|
|
314
|
1183
|
|
|
1183
|
0
|
1711
|
my $watch_check_code = generate_watch_code("logger", 1); |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
my $coderef; |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
if(defined $Log::Log4perl::Config::WATCHER) { |
319
|
|
|
|
|
|
|
$coderef = $watch_check_code; |
320
|
|
|
|
|
|
|
} else { |
321
|
|
|
|
|
|
|
$coderef = sub { undef }; |
322
|
|
|
|
|
|
|
} |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
return $coderef; |
325
|
1183
|
|
|
|
|
2188
|
} |
326
|
|
|
|
|
|
|
|
327
|
1183
|
|
|
|
|
1892
|
################################################## |
328
|
|
|
|
|
|
|
################################################## |
329
|
1183
|
100
|
|
|
|
2239
|
my($return_token) = @_; |
330
|
43
|
|
|
|
|
62
|
|
331
|
|
|
|
|
|
|
return generate_watch_code("checker", $return_token); |
332
|
1140
|
|
|
41
|
|
2819
|
} |
|
41
|
|
|
|
|
89
|
|
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
################################################## |
335
|
1183
|
|
|
|
|
3351
|
################################################## |
336
|
|
|
|
|
|
|
my($type, $return_token) = @_; |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
print "generate_watch_code:\n" if _INTERNAL_DEBUG; |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
# No watcher configured, return a no-op as watch code. |
341
|
10518
|
|
|
10518
|
0
|
15945
|
if(! defined $Log::Log4perl::Config::WATCHER) { |
342
|
|
|
|
|
|
|
return sub { $return_token }; |
343
|
10518
|
|
|
|
|
15738
|
} |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
my $cond = generate_watch_conditional(); |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
return sub { |
348
|
|
|
|
|
|
|
print "exe_watch_code:\n" if _INTERNAL_DEBUG; |
349
|
12487
|
|
|
12487
|
0
|
19034
|
|
350
|
|
|
|
|
|
|
if(_INTERNAL_DEBUG) { |
351
|
12487
|
|
|
|
|
14911
|
print "Next check: ", |
352
|
|
|
|
|
|
|
"$Log::Log4perl::Config::Watch::NEXT_CHECK_TIME ", |
353
|
|
|
|
|
|
|
" Now: ", time(), " Mod: ", |
354
|
12487
|
100
|
|
|
|
21560
|
(stat($Log::Log4perl::Config::WATCHER->file()))[9], |
355
|
12072
|
|
|
106
|
|
47230
|
"\n"; |
|
106
|
|
|
|
|
347
|
|
356
|
|
|
|
|
|
|
} |
357
|
|
|
|
|
|
|
|
358
|
415
|
|
|
|
|
595
|
if( $cond->() ) { |
359
|
|
|
|
|
|
|
my $init_permitted = 1; |
360
|
|
|
|
|
|
|
|
361
|
63
|
|
|
63
|
|
94
|
if(exists $Log::Log4perl::Config::OPTS->{ preinit_callback } ) { |
362
|
|
|
|
|
|
|
print "Calling preinit_callback\n" if _INTERNAL_DEBUG; |
363
|
63
|
|
|
|
|
82
|
$init_permitted = |
364
|
|
|
|
|
|
|
$Log::Log4perl::Config::OPTS->{ preinit_callback }->( |
365
|
|
|
|
|
|
|
Log::Log4perl::Config->watcher()->file() ); |
366
|
|
|
|
|
|
|
print "Callback returned $init_permitted\n" if _INTERNAL_DEBUG; |
367
|
|
|
|
|
|
|
} |
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
if( $init_permitted ) { |
370
|
|
|
|
|
|
|
Log::Log4perl->init_and_watch(); |
371
|
63
|
100
|
|
|
|
136
|
} else { |
372
|
6
|
|
|
|
|
19
|
# It was time to reinit, but init wasn't permitted. |
373
|
|
|
|
|
|
|
# Return true, so that the logger continues as if |
374
|
6
|
100
|
|
|
|
31
|
# it wasn't time to reinit. |
375
|
2
|
|
|
|
|
5
|
return 1; |
376
|
|
|
|
|
|
|
} |
377
|
2
|
|
|
|
|
26
|
|
378
|
|
|
|
|
|
|
my $logger = shift; |
379
|
2
|
|
|
|
|
13
|
my $level = pop; |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
# Forward call to new configuration |
382
|
6
|
100
|
|
|
|
26
|
if($type eq "checker") { |
383
|
5
|
|
|
|
|
59
|
return $logger->$level(); |
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
} elsif( $type eq "logger") { |
386
|
|
|
|
|
|
|
my $methodname = lc($level); |
387
|
|
|
|
|
|
|
|
388
|
1
|
|
|
|
|
5
|
# Bump up the caller level by three, since |
389
|
|
|
|
|
|
|
# we've artificially introduced additional levels. |
390
|
|
|
|
|
|
|
local $Log::Log4perl::caller_depth = |
391
|
5
|
|
|
|
|
13
|
$Log::Log4perl::caller_depth + 3; |
392
|
5
|
|
|
|
|
12
|
|
393
|
|
|
|
|
|
|
# Get a new logger for the same category (the old |
394
|
|
|
|
|
|
|
# logger might be obsolete because of the re-init) |
395
|
5
|
100
|
|
|
|
18
|
$logger = Log::Log4perl::get_logger( $logger->{category} ); |
|
|
50
|
|
|
|
|
|
396
|
2
|
|
|
|
|
13
|
|
397
|
|
|
|
|
|
|
$logger->$methodname(@_); # send the message |
398
|
|
|
|
|
|
|
# to the new configuration |
399
|
3
|
|
|
|
|
11
|
return undef; # Return false, so the logger finishes |
400
|
|
|
|
|
|
|
# prematurely and doesn't log the same |
401
|
|
|
|
|
|
|
# message again. |
402
|
|
|
|
|
|
|
} else { |
403
|
3
|
|
|
|
|
7
|
die "internal error: unknown type"; |
404
|
|
|
|
|
|
|
} |
405
|
|
|
|
|
|
|
} else { |
406
|
|
|
|
|
|
|
if(_INTERNAL_DEBUG) { |
407
|
|
|
|
|
|
|
print "Conditional returned false\n"; |
408
|
3
|
|
|
|
|
14
|
} |
409
|
|
|
|
|
|
|
return $return_token; |
410
|
3
|
|
|
|
|
22
|
} |
411
|
|
|
|
|
|
|
}; |
412
|
3
|
|
|
|
|
43
|
} |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
################################################## |
415
|
|
|
|
|
|
|
################################################## |
416
|
0
|
|
|
|
|
0
|
|
417
|
|
|
|
|
|
|
if(defined $Log::Log4perl::Config::Watch::SIGNAL_CAUGHT) { |
418
|
|
|
|
|
|
|
# In this mode, we just check for the variable indicating |
419
|
57
|
|
|
|
|
81
|
# that the signal has been caught |
420
|
|
|
|
|
|
|
return sub { |
421
|
|
|
|
|
|
|
return $Log::Log4perl::Config::Watch::SIGNAL_CAUGHT; |
422
|
57
|
|
|
|
|
272
|
}; |
423
|
|
|
|
|
|
|
} |
424
|
415
|
|
|
|
|
2700
|
|
425
|
|
|
|
|
|
|
return sub { |
426
|
|
|
|
|
|
|
return |
427
|
|
|
|
|
|
|
( time() > $Log::Log4perl::Config::Watch::NEXT_CHECK_TIME and |
428
|
|
|
|
|
|
|
$Log::Log4perl::Config::WATCHER->change_detected() ); |
429
|
|
|
|
|
|
|
}; |
430
|
|
|
|
|
|
|
} |
431
|
415
|
100
|
|
415
|
0
|
776
|
|
432
|
|
|
|
|
|
|
################################################## |
433
|
|
|
|
|
|
|
################################################## |
434
|
|
|
|
|
|
|
my($string) = @_; |
435
|
16
|
|
|
16
|
|
39
|
|
436
|
110
|
|
|
|
|
306
|
if($string eq "") { |
437
|
|
|
|
|
|
|
return undef; # root doesn't have a parent. |
438
|
|
|
|
|
|
|
} |
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
my @components = split /\./, $string; |
441
|
47
|
|
100
|
47
|
|
257
|
|
442
|
|
|
|
|
|
|
if(@components == 1) { |
443
|
305
|
|
|
|
|
867
|
return ""; |
444
|
|
|
|
|
|
|
} |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
pop @components; |
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
return join('.', @components); |
449
|
2225
|
|
|
2225
|
0
|
3566
|
} |
450
|
|
|
|
|
|
|
|
451
|
2225
|
50
|
|
|
|
4054
|
################################################## |
452
|
0
|
|
|
|
|
0
|
################################################## |
453
|
|
|
|
|
|
|
my($self, $level, $dont_reset_all) = @_; |
454
|
|
|
|
|
|
|
|
455
|
2225
|
|
|
|
|
4883
|
# 'Set' function |
456
|
|
|
|
|
|
|
if(defined $level) { |
457
|
2225
|
100
|
|
|
|
4490
|
croak "invalid level '$level'" |
458
|
1308
|
|
|
|
|
2943
|
unless Log::Log4perl::Level::is_valid($level); |
459
|
|
|
|
|
|
|
if ($level =~ /\D/){ |
460
|
|
|
|
|
|
|
$level = Log::Log4perl::Level::to_priority($level); |
461
|
917
|
|
|
|
|
1341
|
} |
462
|
|
|
|
|
|
|
$self->{level} = $level; |
463
|
917
|
|
|
|
|
2368
|
|
464
|
|
|
|
|
|
|
&reset_all_output_methods |
465
|
|
|
|
|
|
|
unless $dont_reset_all; #keep us from getting overworked |
466
|
|
|
|
|
|
|
#if it's the config file calling us |
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
return $level; |
469
|
1816
|
|
|
1816
|
0
|
4100
|
} |
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
# 'Get' function |
472
|
1816
|
100
|
|
|
|
3730
|
if(defined $self->{level}) { |
473
|
241
|
50
|
|
|
|
898
|
return $self->{level}; |
474
|
|
|
|
|
|
|
} |
475
|
241
|
100
|
|
|
|
897
|
|
476
|
3
|
|
|
|
|
12
|
for(my $logger = $self; $logger; $logger = parent_logger($logger)) { |
477
|
|
|
|
|
|
|
|
478
|
241
|
|
|
|
|
573
|
# Does the current logger have the level defined? |
479
|
|
|
|
|
|
|
|
480
|
241
|
100
|
|
|
|
709
|
if($logger->{category} eq "") { |
481
|
|
|
|
|
|
|
# It's the root logger |
482
|
|
|
|
|
|
|
return $ROOT_LOGGER->{level}; |
483
|
|
|
|
|
|
|
} |
484
|
241
|
|
|
|
|
727
|
|
485
|
|
|
|
|
|
|
if(defined $LOGGERS_BY_NAME->{$logger->{category}}->{level}) { |
486
|
|
|
|
|
|
|
return $LOGGERS_BY_NAME->{$logger->{category}}->{level}; |
487
|
|
|
|
|
|
|
} |
488
|
1575
|
100
|
|
|
|
3656
|
} |
489
|
773
|
|
|
|
|
1993
|
|
490
|
|
|
|
|
|
|
# We should never get here because at least the root logger should |
491
|
|
|
|
|
|
|
# have a level defined |
492
|
802
|
|
|
|
|
2103
|
die "We should never get here."; |
493
|
|
|
|
|
|
|
} |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
################################################## |
496
|
1699
|
100
|
|
|
|
3519
|
# Get the parent of the current logger or undef |
497
|
|
|
|
|
|
|
################################################## |
498
|
743
|
|
|
|
|
1994
|
my($logger) = @_; |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
# Is it the root logger? |
501
|
956
|
100
|
|
|
|
3051
|
if($logger->{category} eq "") { |
502
|
59
|
|
|
|
|
179
|
# Root has no parent |
503
|
|
|
|
|
|
|
return undef; |
504
|
|
|
|
|
|
|
} |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
# Go to the next defined (!) parent |
507
|
|
|
|
|
|
|
my $parent_class = parent_string($logger->{category}); |
508
|
0
|
|
|
|
|
0
|
|
509
|
|
|
|
|
|
|
while($parent_class ne "" and |
510
|
|
|
|
|
|
|
! exists $LOGGERS_BY_NAME->{$parent_class}) { |
511
|
|
|
|
|
|
|
$parent_class = parent_string($parent_class); |
512
|
|
|
|
|
|
|
$logger = $LOGGERS_BY_NAME->{$parent_class}; |
513
|
|
|
|
|
|
|
} |
514
|
|
|
|
|
|
|
|
515
|
2725
|
|
|
2725
|
0
|
4392
|
if($parent_class eq "") { |
516
|
|
|
|
|
|
|
$logger = $ROOT_LOGGER; |
517
|
|
|
|
|
|
|
} else { |
518
|
2725
|
100
|
|
|
|
5369
|
$logger = $LOGGERS_BY_NAME->{$parent_class}; |
519
|
|
|
|
|
|
|
} |
520
|
1141
|
|
|
|
|
2822
|
|
521
|
|
|
|
|
|
|
return $logger; |
522
|
|
|
|
|
|
|
} |
523
|
|
|
|
|
|
|
|
524
|
1584
|
|
|
|
|
2919
|
################################################## |
525
|
|
|
|
|
|
|
################################################## |
526
|
1584
|
|
100
|
|
|
5013
|
my($class) = @_; |
527
|
|
|
|
|
|
|
return $ROOT_LOGGER; |
528
|
641
|
|
|
|
|
1079
|
} |
529
|
641
|
|
|
|
|
1732
|
|
530
|
|
|
|
|
|
|
################################################## |
531
|
|
|
|
|
|
|
################################################## |
532
|
1584
|
100
|
|
|
|
2997
|
my($self, $onoff, $no_reinit) = @_; |
533
|
1308
|
|
|
|
|
1869
|
|
534
|
|
|
|
|
|
|
if(defined $onoff) { |
535
|
276
|
|
|
|
|
424
|
$self->{additivity} = $onoff; |
536
|
|
|
|
|
|
|
} |
537
|
|
|
|
|
|
|
|
538
|
1584
|
|
|
|
|
3451
|
if( ! $no_reinit ) { |
539
|
|
|
|
|
|
|
$self->set_output_methods(); |
540
|
|
|
|
|
|
|
} |
541
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
return $self->{additivity}; |
543
|
|
|
|
|
|
|
} |
544
|
0
|
|
|
0
|
0
|
0
|
|
545
|
0
|
|
|
|
|
0
|
################################################## |
546
|
|
|
|
|
|
|
################################################## |
547
|
|
|
|
|
|
|
my($class, $category) = @_; |
548
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
unless(defined $ROOT_LOGGER) { |
550
|
|
|
|
|
|
|
Carp::confess "Internal error: Root Logger not initialized."; |
551
|
5
|
|
|
5
|
0
|
19
|
} |
552
|
|
|
|
|
|
|
|
553
|
5
|
50
|
|
|
|
15
|
return $ROOT_LOGGER if $category eq ""; |
554
|
5
|
|
|
|
|
115
|
|
555
|
|
|
|
|
|
|
my $logger = $class->_new($category); |
556
|
|
|
|
|
|
|
return $logger; |
557
|
5
|
100
|
|
|
|
87
|
} |
558
|
2
|
|
|
|
|
13
|
|
559
|
|
|
|
|
|
|
################################################## |
560
|
|
|
|
|
|
|
################################################## |
561
|
5
|
|
|
|
|
13
|
my($self, $appender, $dont_reset_all) = @_; |
562
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
# We take this as an indicator that we're initialized. |
564
|
|
|
|
|
|
|
$INITIALIZED = 1; |
565
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
my $appender_name = $appender->name(); |
567
|
439
|
|
|
439
|
0
|
1092
|
|
568
|
|
|
|
|
|
|
$self->{num_appenders}++; #should this be inside the unless? |
569
|
439
|
100
|
|
|
|
1175
|
|
570
|
1
|
|
|
|
|
192
|
# Add newly created appender to the end of the appender array |
571
|
|
|
|
|
|
|
unless (grep{$_ eq $appender_name} @{$self->{appender_names}}){ |
572
|
|
|
|
|
|
|
$self->{appender_names} = [sort @{$self->{appender_names}}, |
573
|
438
|
100
|
|
|
|
1317
|
$appender_name]; |
574
|
|
|
|
|
|
|
} |
575
|
274
|
|
|
|
|
748
|
|
576
|
274
|
|
|
|
|
840
|
$APPENDER_BY_NAME{$appender_name} = $appender; |
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
reset_all_output_methods |
579
|
|
|
|
|
|
|
unless $dont_reset_all; # keep us from getting overworked |
580
|
|
|
|
|
|
|
# if it's the config file calling us |
581
|
|
|
|
|
|
|
|
582
|
214
|
|
|
214
|
0
|
1398
|
# For chaining calls ... |
583
|
|
|
|
|
|
|
return $appender; |
584
|
|
|
|
|
|
|
} |
585
|
214
|
|
|
|
|
419
|
|
586
|
|
|
|
|
|
|
################################################## |
587
|
214
|
|
|
|
|
941
|
################################################## |
588
|
|
|
|
|
|
|
my($self, $appender_name, $dont_reset_all, $sloppy) = @_; |
589
|
214
|
|
|
|
|
484
|
|
590
|
|
|
|
|
|
|
my %appender_names = map { $_ => 1 } @{$self->{appender_names}}; |
591
|
|
|
|
|
|
|
|
592
|
214
|
100
|
|
|
|
368
|
if(!exists $appender_names{$appender_name}) { |
|
15
|
|
|
|
|
62
|
|
|
214
|
|
|
|
|
1114
|
|
593
|
213
|
|
|
|
|
390
|
die "No such appender: $appender_name" unless $sloppy; |
|
213
|
|
|
|
|
738
|
|
594
|
|
|
|
|
|
|
return undef; |
595
|
|
|
|
|
|
|
} |
596
|
|
|
|
|
|
|
|
597
|
214
|
|
|
|
|
584
|
delete $appender_names{$appender_name}; |
598
|
|
|
|
|
|
|
$self->{num_appenders}--; |
599
|
214
|
100
|
|
|
|
617
|
$self->{appender_names} = [sort keys %appender_names]; |
600
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
&reset_all_output_methods |
602
|
|
|
|
|
|
|
unless $dont_reset_all; |
603
|
|
|
|
|
|
|
} |
604
|
214
|
|
|
|
|
1305
|
|
605
|
|
|
|
|
|
|
################################################## |
606
|
|
|
|
|
|
|
################################################## |
607
|
|
|
|
|
|
|
# If someone calls Logger->... and not Logger::... |
608
|
|
|
|
|
|
|
shift if $_[0] eq __PACKAGE__; |
609
|
|
|
|
|
|
|
|
610
|
6
|
|
|
6
|
0
|
14
|
my($appender_name, $dont_reset_all) = @_; |
611
|
|
|
|
|
|
|
|
612
|
6
|
|
|
|
|
9
|
return 0 unless exists |
|
2
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
13
|
|
613
|
|
|
|
|
|
|
$APPENDER_BY_NAME{$appender_name}; |
614
|
6
|
100
|
|
|
|
15
|
|
615
|
4
|
50
|
|
|
|
8
|
# Remove the given appender from all loggers |
616
|
4
|
|
|
|
|
9
|
# and delete all references to it, causing |
617
|
|
|
|
|
|
|
# its DESTROY method to be called. |
618
|
|
|
|
|
|
|
foreach my $logger (values %$LOGGERS_BY_NAME){ |
619
|
2
|
|
|
|
|
4
|
$logger->remove_appender($appender_name, 0, 1); |
620
|
2
|
|
|
|
|
5
|
} |
621
|
2
|
|
|
|
|
8
|
# Also remove it from the root logger |
622
|
|
|
|
|
|
|
$ROOT_LOGGER->remove_appender($appender_name, 0, 1); |
623
|
2
|
50
|
|
|
|
6
|
|
624
|
|
|
|
|
|
|
delete $APPENDER_BY_NAME{$appender_name}; |
625
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
&reset_all_output_methods |
627
|
|
|
|
|
|
|
unless $dont_reset_all; |
628
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
return 1; |
630
|
|
|
|
|
|
|
} |
631
|
1
|
50
|
|
1
|
0
|
5
|
|
632
|
|
|
|
|
|
|
################################################## |
633
|
1
|
|
|
|
|
2
|
################################################## |
634
|
|
|
|
|
|
|
my($self) = @_; |
635
|
|
|
|
|
|
|
|
636
|
1
|
50
|
|
|
|
5
|
return $self->{num_appenders}; |
637
|
|
|
|
|
|
|
} |
638
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
################################################## |
640
|
|
|
|
|
|
|
# external api |
641
|
1
|
|
|
|
|
4
|
################################################## |
642
|
3
|
|
|
|
|
7
|
my ($self, $priority, @messages) = @_; |
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
confess("log: No priority given!") unless defined($priority); |
645
|
1
|
|
|
|
|
4
|
|
646
|
|
|
|
|
|
|
# Just in case of 'init_and_watch' -- see Changes 0.21 |
647
|
1
|
|
|
|
|
2
|
$_[0] = $LOGGERS_BY_NAME->{$_[0]->{category}} if |
648
|
|
|
|
|
|
|
defined $Log::Log4perl::Config::WATCHER; |
649
|
1
|
50
|
|
|
|
5
|
|
650
|
|
|
|
|
|
|
init_warn() unless $INITIALIZED or $NON_INIT_WARNED; |
651
|
|
|
|
|
|
|
|
652
|
1
|
|
|
|
|
4
|
croak "priority $priority isn't numeric" if ($priority =~ /\D/); |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
my $which = Log::Log4perl::Level::to_level($priority); |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
$self->{$which}->($self, @messages, |
657
|
|
|
|
|
|
|
Log::Log4perl::Level::to_level($priority)); |
658
|
0
|
|
|
0
|
0
|
0
|
} |
659
|
|
|
|
|
|
|
|
660
|
0
|
|
|
|
|
0
|
###################################################################### |
661
|
|
|
|
|
|
|
# |
662
|
|
|
|
|
|
|
# create_custom_level |
663
|
|
|
|
|
|
|
# creates a custom level |
664
|
|
|
|
|
|
|
# in theory, could be used to create the default ones |
665
|
|
|
|
|
|
|
###################################################################### |
666
|
|
|
|
|
|
|
###################################################################### |
667
|
11
|
|
|
11
|
0
|
869
|
my $level = shift || die("create_custom_level: " . |
668
|
|
|
|
|
|
|
"forgot to pass in a level string!"); |
669
|
11
|
50
|
|
|
|
26
|
my $after = shift || die("create_custom_level: " . |
670
|
|
|
|
|
|
|
"forgot to pass in a level after which to " . |
671
|
|
|
|
|
|
|
"place the new level!"); |
672
|
|
|
|
|
|
|
my $syslog_equiv = shift; # can be undef |
673
|
11
|
50
|
|
|
|
24
|
my $log_dispatch_level = shift; # optional |
674
|
|
|
|
|
|
|
|
675
|
11
|
0
|
33
|
|
|
25
|
## only let users create custom levels before initialization |
676
|
|
|
|
|
|
|
|
677
|
11
|
50
|
|
|
|
34
|
die("create_custom_level must be called before init or " . |
678
|
|
|
|
|
|
|
"first get_logger() call") if ($INITIALIZED); |
679
|
11
|
|
|
|
|
26
|
|
680
|
|
|
|
|
|
|
my %PRIORITY = %Log::Log4perl::Level::PRIORITY; #convenience |
681
|
11
|
|
|
|
|
27
|
|
682
|
|
|
|
|
|
|
die("create_custom_level: no such level \"$after\"! Use one of: ", |
683
|
|
|
|
|
|
|
join(", ", sort keys %PRIORITY)) unless $PRIORITY{$after}; |
684
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
# figure out new int value by AFTER + (AFTER+ 1) / 2 |
686
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
my $next_prio = Log::Log4perl::Level::get_lower_level($PRIORITY{$after}, 1); |
688
|
|
|
|
|
|
|
my $cust_prio = int(($PRIORITY{$after} + $next_prio) / 2); |
689
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
die(qq{create_custom_level: Calculated level of $cust_prio already exists! |
691
|
|
|
|
|
|
|
This should only happen if you've made some insane number of custom |
692
|
|
|
|
|
|
|
levels (like 15 one after another) |
693
|
33
|
|
50
|
33
|
0
|
22840
|
You can usually fix this by re-arranging your code from: |
694
|
|
|
|
|
|
|
create_custom_level("cust1", X); |
695
|
33
|
|
50
|
|
|
80
|
create_custom_level("cust2", X); |
696
|
|
|
|
|
|
|
create_custom_level("cust3", X); |
697
|
|
|
|
|
|
|
create_custom_level("cust4", X); |
698
|
33
|
|
|
|
|
64
|
create_custom_level("cust5", X); |
699
|
33
|
|
|
|
|
46
|
into: |
700
|
|
|
|
|
|
|
create_custom_level("cust3", X); |
701
|
|
|
|
|
|
|
create_custom_level("cust5", X); |
702
|
|
|
|
|
|
|
create_custom_level("cust4", 4); |
703
|
33
|
100
|
|
|
|
81
|
create_custom_level("cust2", cust3); |
704
|
|
|
|
|
|
|
create_custom_level("cust1", cust2); |
705
|
|
|
|
|
|
|
}) if (${Log::Log4perl::Level::LEVELS{$cust_prio}}); |
706
|
32
|
|
|
|
|
346
|
|
707
|
|
|
|
|
|
|
Log::Log4perl::Level::add_priority($level, $cust_prio, $syslog_equiv, |
708
|
|
|
|
|
|
|
$log_dispatch_level); |
709
|
32
|
50
|
|
|
|
107
|
|
710
|
|
|
|
|
|
|
print("Adding prio $level at $cust_prio\n") if _INTERNAL_DEBUG; |
711
|
|
|
|
|
|
|
|
712
|
|
|
|
|
|
|
# get $LEVEL into namespace of Log::Log4perl::Logger to |
713
|
32
|
|
|
|
|
85
|
# create $logger->foo nd $logger->is_foo |
714
|
32
|
|
|
|
|
101
|
my $name = "Log::Log4perl::Logger::"; |
715
|
|
|
|
|
|
|
my $key = $level; |
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
no strict qw(refs); |
718
|
|
|
|
|
|
|
# be sure to use ${Log...} as CVS adds log entries for Log |
719
|
|
|
|
|
|
|
*{"$name$key"} = \${Log::Log4perl::Level::PRIORITY{$level}}; |
720
|
|
|
|
|
|
|
|
721
|
|
|
|
|
|
|
# now, stick it in the caller's namespace |
722
|
|
|
|
|
|
|
$name = caller(0) . "::"; |
723
|
|
|
|
|
|
|
*{"$name$key"} = \${Log::Log4perl::Level::PRIORITY{$level}}; |
724
|
|
|
|
|
|
|
use strict qw(refs); |
725
|
|
|
|
|
|
|
|
726
|
|
|
|
|
|
|
create_log_level_methods($level); |
727
|
|
|
|
|
|
|
|
728
|
|
|
|
|
|
|
return 0; |
729
|
|
|
|
|
|
|
|
730
|
|
|
|
|
|
|
} |
731
|
32
|
100
|
|
|
|
112
|
|
732
|
|
|
|
|
|
|
######################################## |
733
|
31
|
|
|
|
|
87
|
# |
734
|
|
|
|
|
|
|
# if we were hackin' lisp (or scheme), we'd be returning some lambda |
735
|
|
|
|
|
|
|
# expressions. But we aren't. :) So we'll just create some strings and |
736
|
31
|
|
|
|
|
42
|
# eval them. |
737
|
|
|
|
|
|
|
######################################## |
738
|
|
|
|
|
|
|
######################################## |
739
|
|
|
|
|
|
|
my $level = shift || die("create_log_level_methods: " . |
740
|
31
|
|
|
|
|
53
|
"forgot to pass in a level string!"); |
741
|
31
|
|
|
|
|
49
|
my $lclevel = lc($level); |
742
|
|
|
|
|
|
|
my $levelint = uc($level) . "_INT"; |
743
|
70
|
|
|
70
|
|
667
|
my $initial_cap = ucfirst($lclevel); |
|
70
|
|
|
|
|
193
|
|
|
70
|
|
|
|
|
6374
|
|
744
|
|
|
|
|
|
|
|
745
|
31
|
|
|
|
|
52
|
no strict qw(refs); |
|
31
|
|
|
|
|
188
|
|
746
|
|
|
|
|
|
|
|
747
|
|
|
|
|
|
|
# This is a bit better way to create code on the fly than eval'ing strings. |
748
|
31
|
|
|
|
|
78
|
# -erik |
749
|
31
|
|
|
|
|
56
|
|
|
31
|
|
|
|
|
96
|
|
750
|
70
|
|
|
70
|
|
500
|
*{__PACKAGE__ . "::$lclevel"} = sub { |
|
70
|
|
|
|
|
179
|
|
|
70
|
|
|
|
|
9571
|
|
751
|
|
|
|
|
|
|
if(_INTERNAL_DEBUG) { |
752
|
31
|
|
|
|
|
76
|
my $level_disp = (defined $_[0]->{level} ? $_[0]->{level} |
753
|
|
|
|
|
|
|
: "[undef]"); |
754
|
31
|
|
|
|
|
178
|
print "$lclevel: ($_[0]->{category}/$level_disp) [@_]\n"; |
755
|
|
|
|
|
|
|
} |
756
|
|
|
|
|
|
|
init_warn() unless $INITIALIZED or $NON_INIT_WARNED; |
757
|
|
|
|
|
|
|
$_[0]->{$level}->(@_, $level) if defined $_[0]->{$level}; |
758
|
|
|
|
|
|
|
}; |
759
|
|
|
|
|
|
|
|
760
|
|
|
|
|
|
|
# Added these to have is_xxx functions as fast as xxx functions |
761
|
|
|
|
|
|
|
# -ms |
762
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
my $islevel = "is_" . $level; |
764
|
|
|
|
|
|
|
my $islclevel = "is_" . $lclevel; |
765
|
|
|
|
|
|
|
|
766
|
591
|
|
50
|
591
|
0
|
1473
|
*{__PACKAGE__ . "::is_$lclevel"} = sub { |
767
|
|
|
|
|
|
|
$_[0]->{$islevel}->($_[0], $islclevel); |
768
|
591
|
|
|
|
|
1293
|
}; |
769
|
591
|
|
|
|
|
1165
|
|
770
|
591
|
|
|
|
|
1126
|
# Add the isXxxEnabled() methods as identical to the is_xxx |
771
|
|
|
|
|
|
|
# functions. - dviner |
772
|
70
|
|
|
70
|
|
603
|
|
|
70
|
|
|
|
|
167
|
|
|
70
|
|
|
|
|
20532
|
|
773
|
|
|
|
|
|
|
*{__PACKAGE__ . "::is".$initial_cap."Enabled"} = |
774
|
|
|
|
|
|
|
\&{__PACKAGE__ . "::is_$lclevel"}; |
775
|
|
|
|
|
|
|
|
776
|
|
|
|
|
|
|
use strict qw(refs); |
777
|
591
|
|
|
|
|
3379
|
|
778
|
436
|
|
|
436
|
|
6029911
|
return 0; |
779
|
|
|
|
|
|
|
} |
780
|
|
|
|
|
|
|
|
781
|
|
|
|
|
|
|
#now lets autogenerate the logger subs based on the defined priorities |
782
|
|
|
|
|
|
|
foreach my $level (keys %Log::Log4perl::Level::PRIORITY){ |
783
|
436
|
50
|
66
|
|
|
1086
|
create_log_level_methods($level); |
784
|
436
|
50
|
|
|
|
1790
|
} |
785
|
591
|
|
|
|
|
2604
|
|
786
|
|
|
|
|
|
|
################################################## |
787
|
|
|
|
|
|
|
################################################## |
788
|
|
|
|
|
|
|
CORE::warn "Log4perl: Seems like no initialization happened. " . |
789
|
|
|
|
|
|
|
"Forgot to call init()?\n"; |
790
|
591
|
|
|
|
|
1399
|
# Only tell this once; |
791
|
591
|
|
|
|
|
1094
|
$NON_INIT_WARNED = 1; |
792
|
|
|
|
|
|
|
} |
793
|
591
|
|
|
|
|
2662
|
|
794
|
144
|
|
|
144
|
|
3242
|
####################################################### |
795
|
591
|
|
|
|
|
2337
|
# call me from a sub-func to spew the sub-func's caller |
796
|
|
|
|
|
|
|
####################################################### |
797
|
|
|
|
|
|
|
my $message = join ('', @_); |
798
|
|
|
|
|
|
|
|
799
|
|
|
|
|
|
|
my $caller_offset = |
800
|
591
|
|
|
|
|
2330
|
Log::Log4perl::caller_depth_offset( |
801
|
591
|
|
|
|
|
1032
|
$Log::Log4perl::caller_depth + 1 ); |
|
591
|
|
|
|
|
1415
|
|
802
|
|
|
|
|
|
|
|
803
|
70
|
|
|
70
|
|
584
|
my ($pack, $file, $line) = caller($caller_offset); |
|
70
|
|
|
|
|
194
|
|
|
70
|
|
|
|
|
114961
|
|
804
|
|
|
|
|
|
|
|
805
|
591
|
|
|
|
|
1319
|
if (not chomp $message) { # no newline |
806
|
|
|
|
|
|
|
$message .= " at $file line $line"; |
807
|
|
|
|
|
|
|
|
808
|
|
|
|
|
|
|
# Someday, we'll use Threads. Really. |
809
|
|
|
|
|
|
|
if (defined &Thread::tid) { |
810
|
|
|
|
|
|
|
my $tid = Thread->self->tid; |
811
|
|
|
|
|
|
|
$message .= " thread $tid" if $tid; |
812
|
|
|
|
|
|
|
} |
813
|
|
|
|
|
|
|
} |
814
|
|
|
|
|
|
|
|
815
|
|
|
|
|
|
|
return ($message, "\n"); |
816
|
1
|
|
|
1
|
0
|
58
|
} |
817
|
|
|
|
|
|
|
|
818
|
|
|
|
|
|
|
####################################################### |
819
|
1
|
|
|
|
|
7
|
####################################################### |
820
|
|
|
|
|
|
|
my $self = shift; |
821
|
|
|
|
|
|
|
CORE::warn(callerline($self->warning_render(@_))); |
822
|
|
|
|
|
|
|
} |
823
|
|
|
|
|
|
|
|
824
|
|
|
|
|
|
|
####################################################### |
825
|
|
|
|
|
|
|
####################################################### |
826
|
32
|
|
|
32
|
0
|
79
|
my $self = shift; |
827
|
|
|
|
|
|
|
my $arg = $_[0]; |
828
|
32
|
|
|
|
|
82
|
|
829
|
|
|
|
|
|
|
my($msg) = callerline($self->warning_render(@_)); |
830
|
|
|
|
|
|
|
|
831
|
|
|
|
|
|
|
if($DIE_DEBUG) { |
832
|
32
|
|
|
|
|
211
|
$DIE_DEBUG_BUFFER = "DIE_DEBUG: $msg"; |
833
|
|
|
|
|
|
|
} else { |
834
|
32
|
100
|
|
|
|
107
|
if( $Log::Log4perl::STRINGIFY_DIE_MESSAGE ) { |
835
|
27
|
|
|
|
|
87
|
die("$msg\n"); |
836
|
|
|
|
|
|
|
} |
837
|
|
|
|
|
|
|
die $arg; |
838
|
27
|
50
|
|
|
|
67
|
} |
839
|
0
|
|
|
|
|
0
|
} |
840
|
0
|
0
|
|
|
|
0
|
|
841
|
|
|
|
|
|
|
################################################## |
842
|
|
|
|
|
|
|
################################################## |
843
|
|
|
|
|
|
|
my $self = shift; |
844
|
32
|
|
|
|
|
237
|
|
845
|
|
|
|
|
|
|
local $Log::Log4perl::caller_depth = |
846
|
|
|
|
|
|
|
$Log::Log4perl::caller_depth + 1; |
847
|
|
|
|
|
|
|
|
848
|
|
|
|
|
|
|
if ($self->is_warn()) { |
849
|
|
|
|
|
|
|
# Since we're one caller level off now, compensate for that. |
850
|
9
|
|
|
9
|
0
|
14
|
my @chomped = @_; |
851
|
9
|
|
|
|
|
21
|
chomp($chomped[-1]); |
852
|
|
|
|
|
|
|
$self->warn(@chomped); |
853
|
|
|
|
|
|
|
} |
854
|
|
|
|
|
|
|
|
855
|
|
|
|
|
|
|
$self->and_warn(@_); |
856
|
|
|
|
|
|
|
} |
857
|
11
|
|
|
11
|
0
|
21
|
|
858
|
11
|
|
|
|
|
16
|
################################################## |
859
|
|
|
|
|
|
|
################################################## |
860
|
11
|
|
|
|
|
27
|
my $self = shift; |
861
|
|
|
|
|
|
|
|
862
|
11
|
100
|
|
|
|
27
|
local $Log::Log4perl::caller_depth = |
863
|
1
|
|
|
|
|
5
|
$Log::Log4perl::caller_depth + 1; |
864
|
|
|
|
|
|
|
|
865
|
10
|
100
|
|
|
|
20
|
if ($self->is_fatal()) { |
866
|
9
|
|
|
|
|
77
|
# Since we're one caller level off now, compensate for that. |
867
|
|
|
|
|
|
|
my @chomped = @_; |
868
|
1
|
|
|
|
|
8
|
chomp($chomped[-1]); |
869
|
|
|
|
|
|
|
$self->fatal(@chomped); |
870
|
|
|
|
|
|
|
} |
871
|
|
|
|
|
|
|
|
872
|
|
|
|
|
|
|
$Log::Log4perl::LOGDIE_MESSAGE_ON_STDERR ? |
873
|
|
|
|
|
|
|
$self->and_die(@_) : |
874
|
|
|
|
|
|
|
exit($Log::Log4perl::LOGEXIT_CODE); |
875
|
6
|
|
|
6
|
0
|
1564
|
} |
876
|
|
|
|
|
|
|
|
877
|
6
|
|
|
|
|
13
|
################################################## |
878
|
|
|
|
|
|
|
################################################## |
879
|
|
|
|
|
|
|
my $self = shift; |
880
|
6
|
100
|
|
|
|
16
|
|
881
|
|
|
|
|
|
|
local $Log::Log4perl::caller_depth = |
882
|
4
|
|
|
|
|
10
|
$Log::Log4perl::caller_depth + 1; |
883
|
4
|
|
|
|
|
9
|
|
884
|
4
|
|
|
|
|
10
|
if ($self->is_fatal()) { |
885
|
|
|
|
|
|
|
# Since we're one caller level off now, compensate for that. |
886
|
|
|
|
|
|
|
my @chomped = @_; |
887
|
6
|
|
|
|
|
18
|
chomp($chomped[-1]); |
888
|
|
|
|
|
|
|
$self->fatal(@chomped); |
889
|
|
|
|
|
|
|
} |
890
|
|
|
|
|
|
|
|
891
|
|
|
|
|
|
|
exit $Log::Log4perl::LOGEXIT_CODE; |
892
|
|
|
|
|
|
|
} |
893
|
8
|
|
|
8
|
0
|
3092
|
|
894
|
|
|
|
|
|
|
################################################## |
895
|
8
|
|
|
|
|
16
|
# clucks and carps are WARN level |
896
|
|
|
|
|
|
|
################################################## |
897
|
|
|
|
|
|
|
my $self = shift; |
898
|
8
|
100
|
|
|
|
17
|
|
899
|
|
|
|
|
|
|
local $Log::Log4perl::caller_depth = |
900
|
7
|
|
|
|
|
15
|
$Log::Log4perl::caller_depth + 1; |
901
|
7
|
|
|
|
|
15
|
|
902
|
7
|
|
|
|
|
15
|
local $Carp::CarpLevel = |
903
|
|
|
|
|
|
|
$Carp::CarpLevel + 1; |
904
|
|
|
|
|
|
|
|
905
|
|
|
|
|
|
|
my $msg = $self->warning_render(@_); |
906
|
8
|
50
|
|
|
|
30
|
|
907
|
|
|
|
|
|
|
if ($self->is_warn()) { |
908
|
|
|
|
|
|
|
my $message = Carp::longmess($msg); |
909
|
|
|
|
|
|
|
foreach (split(/\n/, $message)) { |
910
|
|
|
|
|
|
|
$self->warn("$_\n"); |
911
|
|
|
|
|
|
|
} |
912
|
|
|
|
|
|
|
} |
913
|
0
|
|
|
0
|
0
|
0
|
|
914
|
|
|
|
|
|
|
Carp::cluck($msg); |
915
|
0
|
|
|
|
|
0
|
} |
916
|
|
|
|
|
|
|
|
917
|
|
|
|
|
|
|
################################################## |
918
|
0
|
0
|
|
|
|
0
|
################################################## |
919
|
|
|
|
|
|
|
my $self = shift; |
920
|
0
|
|
|
|
|
0
|
|
921
|
0
|
|
|
|
|
0
|
local $Carp::CarpLevel = $Carp::CarpLevel + 1; |
922
|
0
|
|
|
|
|
0
|
|
923
|
|
|
|
|
|
|
local $Log::Log4perl::caller_depth = |
924
|
|
|
|
|
|
|
$Log::Log4perl::caller_depth + 1; |
925
|
0
|
|
|
|
|
0
|
|
926
|
|
|
|
|
|
|
my $msg = $self->warning_render(@_); |
927
|
|
|
|
|
|
|
|
928
|
|
|
|
|
|
|
if ($self->is_warn()) { |
929
|
|
|
|
|
|
|
my $message = Carp::shortmess($msg); |
930
|
|
|
|
|
|
|
foreach (split(/\n/, $message)) { |
931
|
|
|
|
|
|
|
$self->warn("$_\n"); |
932
|
4
|
|
|
4
|
0
|
1461
|
} |
933
|
|
|
|
|
|
|
} |
934
|
4
|
|
|
|
|
9
|
|
935
|
|
|
|
|
|
|
Carp::carp($msg); |
936
|
|
|
|
|
|
|
} |
937
|
4
|
|
|
|
|
7
|
|
938
|
|
|
|
|
|
|
################################################## |
939
|
|
|
|
|
|
|
# croaks and confess are FATAL level |
940
|
4
|
|
|
|
|
11
|
################################################## |
941
|
|
|
|
|
|
|
################################################## |
942
|
4
|
100
|
|
|
|
13
|
my $self = shift; |
943
|
2
|
|
|
|
|
134
|
my $arg = $_[0]; |
944
|
2
|
|
|
|
|
227
|
|
945
|
6
|
|
|
|
|
19
|
my $msg = $self->warning_render(@_); |
946
|
|
|
|
|
|
|
|
947
|
|
|
|
|
|
|
local $Carp::CarpLevel = |
948
|
|
|
|
|
|
|
$Carp::CarpLevel + 1; |
949
|
4
|
|
|
|
|
304
|
|
950
|
|
|
|
|
|
|
local $Log::Log4perl::caller_depth = |
951
|
|
|
|
|
|
|
$Log::Log4perl::caller_depth + 1; |
952
|
|
|
|
|
|
|
|
953
|
|
|
|
|
|
|
if ($self->is_fatal()) { |
954
|
|
|
|
|
|
|
my $message = Carp::shortmess($msg); |
955
|
11
|
|
|
11
|
0
|
1471
|
foreach (split(/\n/, $message)) { |
956
|
|
|
|
|
|
|
$self->fatal("$_\n"); |
957
|
11
|
|
|
|
|
24
|
} |
958
|
|
|
|
|
|
|
} |
959
|
11
|
|
|
|
|
21
|
|
960
|
|
|
|
|
|
|
my $croak_msg = $arg; |
961
|
|
|
|
|
|
|
|
962
|
11
|
|
|
|
|
32
|
if( $Log::Log4perl::STRINGIFY_DIE_MESSAGE ) { |
963
|
|
|
|
|
|
|
$croak_msg = $msg; |
964
|
11
|
100
|
|
|
|
32
|
} |
965
|
9
|
|
|
|
|
1081
|
|
966
|
9
|
|
|
|
|
312
|
$Log::Log4perl::LOGDIE_MESSAGE_ON_STDERR ? |
967
|
13
|
|
|
|
|
49
|
Carp::croak($croak_msg) : |
968
|
|
|
|
|
|
|
exit($Log::Log4perl::LOGEXIT_CODE); |
969
|
|
|
|
|
|
|
} |
970
|
|
|
|
|
|
|
|
971
|
11
|
|
|
|
|
1243
|
################################################## |
972
|
|
|
|
|
|
|
################################################## |
973
|
|
|
|
|
|
|
my $self = shift; |
974
|
|
|
|
|
|
|
my $arg = $_[0]; |
975
|
|
|
|
|
|
|
|
976
|
|
|
|
|
|
|
local $Carp::CarpLevel = |
977
|
|
|
|
|
|
|
$Carp::CarpLevel + 1; |
978
|
|
|
|
|
|
|
|
979
|
7
|
|
|
7
|
0
|
1513
|
local $Log::Log4perl::caller_depth = |
980
|
7
|
|
|
|
|
13
|
$Log::Log4perl::caller_depth + 1; |
981
|
|
|
|
|
|
|
|
982
|
7
|
|
|
|
|
21
|
my $msg = $self->warning_render(@_); |
983
|
|
|
|
|
|
|
|
984
|
7
|
|
|
|
|
17
|
if ($self->is_fatal()) { |
985
|
|
|
|
|
|
|
my $message = Carp::longmess($msg); |
986
|
|
|
|
|
|
|
foreach (split(/\n/, $message)) { |
987
|
7
|
|
|
|
|
11
|
$self->fatal("$_\n"); |
988
|
|
|
|
|
|
|
} |
989
|
|
|
|
|
|
|
} |
990
|
7
|
100
|
|
|
|
19
|
|
991
|
6
|
|
|
|
|
686
|
my $confess_msg = $arg; |
992
|
6
|
|
|
|
|
481
|
|
993
|
15
|
|
|
|
|
54
|
if( $Log::Log4perl::STRINGIFY_DIE_MESSAGE ) { |
994
|
|
|
|
|
|
|
$confess_msg = $msg; |
995
|
|
|
|
|
|
|
} |
996
|
|
|
|
|
|
|
|
997
|
7
|
|
|
|
|
17
|
$Log::Log4perl::LOGDIE_MESSAGE_ON_STDERR ? |
998
|
|
|
|
|
|
|
confess($confess_msg) : |
999
|
7
|
100
|
|
|
|
26
|
exit($Log::Log4perl::LOGEXIT_CODE); |
1000
|
6
|
|
|
|
|
14
|
} |
1001
|
|
|
|
|
|
|
|
1002
|
|
|
|
|
|
|
################################################## |
1003
|
|
|
|
|
|
|
# in case people prefer to use error for warning |
1004
|
7
|
50
|
|
|
|
617
|
################################################## |
1005
|
|
|
|
|
|
|
################################################## |
1006
|
|
|
|
|
|
|
my $self = shift; |
1007
|
|
|
|
|
|
|
|
1008
|
|
|
|
|
|
|
local $Log::Log4perl::caller_depth = |
1009
|
|
|
|
|
|
|
$Log::Log4perl::caller_depth + 1; |
1010
|
|
|
|
|
|
|
|
1011
|
5
|
|
|
5
|
0
|
1636
|
if ($self->is_error()) { |
1012
|
5
|
|
|
|
|
9
|
$self->error(@_); |
1013
|
|
|
|
|
|
|
} |
1014
|
5
|
|
|
|
|
10
|
|
1015
|
|
|
|
|
|
|
$self->and_warn(@_); |
1016
|
|
|
|
|
|
|
} |
1017
|
5
|
|
|
|
|
7
|
|
1018
|
|
|
|
|
|
|
################################################## |
1019
|
|
|
|
|
|
|
################################################## |
1020
|
5
|
|
|
|
|
14
|
my $self = shift; |
1021
|
|
|
|
|
|
|
|
1022
|
5
|
100
|
|
|
|
18
|
local $Log::Log4perl::caller_depth = |
1023
|
4
|
|
|
|
|
256
|
$Log::Log4perl::caller_depth + 1; |
1024
|
4
|
|
|
|
|
499
|
|
1025
|
13
|
|
|
|
|
43
|
my $msg = $self->warning_render(@_); |
1026
|
|
|
|
|
|
|
|
1027
|
|
|
|
|
|
|
if ($self->is_error()) { |
1028
|
|
|
|
|
|
|
$self->error($msg); |
1029
|
5
|
|
|
|
|
11
|
} |
1030
|
|
|
|
|
|
|
|
1031
|
5
|
100
|
|
|
|
12
|
$Log::Log4perl::LOGDIE_MESSAGE_ON_STDERR ? |
1032
|
4
|
|
|
|
|
9
|
$self->and_die($msg) : |
1033
|
|
|
|
|
|
|
exit($Log::Log4perl::LOGEXIT_CODE); |
1034
|
|
|
|
|
|
|
} |
1035
|
|
|
|
|
|
|
|
1036
|
5
|
50
|
|
|
|
274
|
################################################## |
1037
|
|
|
|
|
|
|
################################################## |
1038
|
|
|
|
|
|
|
my ($self) = shift; |
1039
|
|
|
|
|
|
|
return $self->dec_level(@_); |
1040
|
|
|
|
|
|
|
} |
1041
|
|
|
|
|
|
|
|
1042
|
|
|
|
|
|
|
################################################## |
1043
|
|
|
|
|
|
|
################################################## |
1044
|
|
|
|
|
|
|
my ($self, $delta) = @_; |
1045
|
3
|
|
|
3
|
0
|
788
|
|
1046
|
|
|
|
|
|
|
$delta ||= 1; |
1047
|
3
|
|
|
|
|
7
|
|
1048
|
|
|
|
|
|
|
$self->level(Log::Log4perl::Level::get_higher_level($self->level(), |
1049
|
|
|
|
|
|
|
$delta)); |
1050
|
3
|
100
|
|
|
|
7
|
|
1051
|
2
|
|
|
|
|
5
|
$self->set_output_methods; |
1052
|
|
|
|
|
|
|
} |
1053
|
|
|
|
|
|
|
|
1054
|
3
|
|
|
|
|
14
|
################################################## |
1055
|
|
|
|
|
|
|
################################################## |
1056
|
|
|
|
|
|
|
my ($self) = shift; |
1057
|
|
|
|
|
|
|
return $self->inc_level(@_); |
1058
|
|
|
|
|
|
|
} |
1059
|
|
|
|
|
|
|
|
1060
|
3
|
|
|
3
|
0
|
795
|
################################################## |
1061
|
|
|
|
|
|
|
################################################## |
1062
|
3
|
|
|
|
|
7
|
my ($self, $delta) = @_; |
1063
|
|
|
|
|
|
|
|
1064
|
|
|
|
|
|
|
$delta ||= 1; |
1065
|
3
|
|
|
|
|
8
|
|
1066
|
|
|
|
|
|
|
$self->level(Log::Log4perl::Level::get_lower_level($self->level(), $delta)); |
1067
|
3
|
100
|
|
|
|
7
|
|
1068
|
2
|
|
|
|
|
5
|
$self->set_output_methods; |
1069
|
|
|
|
|
|
|
} |
1070
|
|
|
|
|
|
|
|
1071
|
|
|
|
|
|
|
1; |
1072
|
3
|
50
|
|
|
|
29
|
|
1073
|
|
|
|
|
|
|
|
1074
|
|
|
|
|
|
|
=encoding utf8 |
1075
|
|
|
|
|
|
|
|
1076
|
|
|
|
|
|
|
=head1 NAME |
1077
|
|
|
|
|
|
|
|
1078
|
|
|
|
|
|
|
Log::Log4perl::Logger - Main Logger Class |
1079
|
4
|
|
|
4
|
0
|
10
|
|
1080
|
4
|
|
|
|
|
12
|
=head1 SYNOPSIS |
1081
|
|
|
|
|
|
|
|
1082
|
|
|
|
|
|
|
# It's not here |
1083
|
|
|
|
|
|
|
|
1084
|
|
|
|
|
|
|
=head1 DESCRIPTION |
1085
|
|
|
|
|
|
|
|
1086
|
2
|
|
|
2
|
0
|
5
|
While everything that makes Log4perl tick is implemented here, |
1087
|
|
|
|
|
|
|
please refer to L<Log::Log4perl> for documentation. |
1088
|
2
|
|
50
|
|
|
8
|
|
1089
|
|
|
|
|
|
|
=head1 LICENSE |
1090
|
2
|
|
|
|
|
8
|
|
1091
|
|
|
|
|
|
|
Copyright 2002-2013 by Mike Schilli E<lt>m@perlmeister.comE<gt> |
1092
|
|
|
|
|
|
|
and Kevin Goess E<lt>cpan@goess.orgE<gt>. |
1093
|
2
|
|
|
|
|
9
|
|
1094
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
1095
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
1096
|
|
|
|
|
|
|
|
1097
|
|
|
|
|
|
|
=head1 AUTHOR |
1098
|
|
|
|
|
|
|
|
1099
|
1
|
|
|
1
|
0
|
5
|
Please contribute patches to the project on Github: |
1100
|
1
|
|
|
|
|
7
|
|
1101
|
|
|
|
|
|
|
http://github.com/mschilli/log4perl |
1102
|
|
|
|
|
|
|
|
1103
|
|
|
|
|
|
|
Send bug reports or requests for enhancements to the authors via our |
1104
|
|
|
|
|
|
|
|
1105
|
|
|
|
|
|
|
MAILING LIST (questions, bug reports, suggestions/patches): |
1106
|
5
|
|
|
5
|
0
|
21
|
log4perl-devel@lists.sourceforge.net |
1107
|
|
|
|
|
|
|
|
1108
|
5
|
|
100
|
|
|
25
|
Authors (please contact them via the list above, not directly): |
1109
|
|
|
|
|
|
|
Mike Schilli <m@perlmeister.com>, |
1110
|
5
|
|
|
|
|
14
|
Kevin Goess <cpan@goess.org> |
1111
|
|
|
|
|
|
|
|
1112
|
5
|
|
|
|
|
14
|
Contributors (in alphabetical order): |
1113
|
|
|
|
|
|
|
Ateeq Altaf, Cory Bennett, Jens Berthold, Jeremy Bopp, Hutton |
1114
|
|
|
|
|
|
|
Davidson, Chris R. Donnelly, Matisse Enzer, Hugh Esco, Anthony |
1115
|
|
|
|
|
|
|
Foiani, James FitzGibbon, Carl Franks, Dennis Gregorovic, Andy |
1116
|
|
|
|
|
|
|
Grundman, Paul Harrington, Alexander Hartmaier David Hull, |
1117
|
|
|
|
|
|
|
Robert Jacobson, Jason Kohles, Jeff Macdonald, Markus Peter, |
1118
|
|
|
|
|
|
|
Brett Rann, Peter Rabbitson, Erik Selberg, Aaron Straup Cope, |
1119
|
|
|
|
|
|
|
Lars Thegler, David Viner, Mac Yang. |
1120
|
|
|
|
|
|
|
|