line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
################################################## |
2
|
|
|
|
|
|
|
################################################## |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use 5.006; |
5
|
70
|
|
|
70
|
|
1287
|
use strict; |
|
70
|
|
|
|
|
248
|
|
6
|
70
|
|
|
70
|
|
370
|
use warnings; |
|
70
|
|
|
|
|
140
|
|
|
70
|
|
|
|
|
3673
|
|
7
|
70
|
|
|
70
|
|
560
|
|
|
70
|
|
|
|
|
179
|
|
|
70
|
|
|
|
|
17114
|
|
8
|
|
|
|
|
|
|
our %MDC_HASH = (); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
########################################### |
11
|
|
|
|
|
|
|
########################################### |
12
|
|
|
|
|
|
|
my($class, $key) = @_; |
13
|
|
|
|
|
|
|
|
14
|
6
|
|
|
6
|
1
|
29
|
if($class ne __PACKAGE__) { |
15
|
|
|
|
|
|
|
# Somebody called us with Log::Log4perl::MDC::get($key) |
16
|
6
|
50
|
|
|
|
20
|
$key = $class; |
17
|
|
|
|
|
|
|
} |
18
|
0
|
|
|
|
|
0
|
|
19
|
|
|
|
|
|
|
if(exists $MDC_HASH{$key}) { |
20
|
|
|
|
|
|
|
return $MDC_HASH{$key}; |
21
|
6
|
100
|
|
|
|
25
|
} else { |
22
|
3
|
|
|
|
|
9
|
return undef; |
23
|
|
|
|
|
|
|
} |
24
|
3
|
|
|
|
|
12
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
########################################### |
27
|
|
|
|
|
|
|
########################################### |
28
|
|
|
|
|
|
|
my($class, $key, $value) = @_; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
if($class ne __PACKAGE__) { |
31
|
3
|
|
|
3
|
1
|
23
|
# Somebody called us with Log::Log4perl::MDC::put($key, $value) |
32
|
|
|
|
|
|
|
$value = $key; |
33
|
3
|
50
|
|
|
|
13
|
$key = $class; |
34
|
|
|
|
|
|
|
} |
35
|
0
|
|
|
|
|
0
|
|
36
|
0
|
|
|
|
|
0
|
$MDC_HASH{$key} = $value; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
3
|
|
|
|
|
11
|
########################################### |
40
|
|
|
|
|
|
|
########################################### |
41
|
|
|
|
|
|
|
%MDC_HASH = (); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
} |
45
|
1
|
|
|
1
|
1
|
4
|
|
46
|
|
|
|
|
|
|
########################################### |
47
|
1
|
|
|
|
|
3
|
########################################### |
48
|
|
|
|
|
|
|
return \%MDC_HASH; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
2
|
|
|
2
|
1
|
6
|
|
54
|
|
|
|
|
|
|
=encoding utf8 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 NAME |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Log::Log4perl::MDC - Mapped Diagnostic Context |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 DESCRIPTION |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Log::Log4perl allows loggers to maintain global thread-specific data, |
63
|
|
|
|
|
|
|
called the Nested Diagnostic Context (NDC) and |
64
|
|
|
|
|
|
|
Mapped Diagnostic Context (MDC). |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
The MDC is a simple thread-specific hash table, in which the application |
67
|
|
|
|
|
|
|
can stuff values under certain keys and retrieve them later |
68
|
|
|
|
|
|
|
via the C<"%X{key}"> placeholder in |
69
|
|
|
|
|
|
|
C<Log::Log4perl::Layout::PatternLayout>s. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=over 4 |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item Log::Log4perl::MDC->put($key, $value); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Store a value C<$value> under key C<$key> in the map. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item my $value = Log::Log4perl::MDC->get($key); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Retrieve the content of the map under the specified key. |
80
|
|
|
|
|
|
|
Typically done by C<%X{key}> in |
81
|
|
|
|
|
|
|
C<Log::Log4perl::Layout::PatternLayout>. |
82
|
|
|
|
|
|
|
If no value exists to the given key, C<undef> is returned. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item my $text = Log::Log4perl::MDC->remove(); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Delete all entries from the map. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item Log::Log4perl::MDC->get_context(); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Returns a reference to the hash table. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=back |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Please note that all of the methods above are class methods, there's no |
95
|
|
|
|
|
|
|
instances of this class. Since the thread model in perl 5.8.0 is |
96
|
|
|
|
|
|
|
"no shared data unless explicitly requested" the data structures |
97
|
|
|
|
|
|
|
used are just global (and therefore thread-specific). |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 LICENSE |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Copyright 2002-2013 by Mike Schilli E<lt>m@perlmeister.comE<gt> |
102
|
|
|
|
|
|
|
and Kevin Goess E<lt>cpan@goess.orgE<gt>. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
105
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 AUTHOR |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Please contribute patches to the project on Github: |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
http://github.com/mschilli/log4perl |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Send bug reports or requests for enhancements to the authors via our |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
MAILING LIST (questions, bug reports, suggestions/patches): |
116
|
|
|
|
|
|
|
log4perl-devel@lists.sourceforge.net |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Authors (please contact them via the list above, not directly): |
119
|
|
|
|
|
|
|
Mike Schilli <m@perlmeister.com>, |
120
|
|
|
|
|
|
|
Kevin Goess <cpan@goess.org> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Contributors (in alphabetical order): |
123
|
|
|
|
|
|
|
Ateeq Altaf, Cory Bennett, Jens Berthold, Jeremy Bopp, Hutton |
124
|
|
|
|
|
|
|
Davidson, Chris R. Donnelly, Matisse Enzer, Hugh Esco, Anthony |
125
|
|
|
|
|
|
|
Foiani, James FitzGibbon, Carl Franks, Dennis Gregorovic, Andy |
126
|
|
|
|
|
|
|
Grundman, Paul Harrington, Alexander Hartmaier David Hull, |
127
|
|
|
|
|
|
|
Robert Jacobson, Jason Kohles, Jeff Macdonald, Markus Peter, |
128
|
|
|
|
|
|
|
Brett Rann, Peter Rabbitson, Erik Selberg, Aaron Straup Cope, |
129
|
|
|
|
|
|
|
Lars Thegler, David Viner, Mac Yang. |
130
|
|
|
|
|
|
|
|