line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Memcached::Client::Log; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
8
|
|
|
8
|
|
208
|
$Memcached::Client::Log::VERSION = '2.01'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
# ABSTRACT: Logging support for Memcached::Client |
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
40
|
use strict; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
227
|
|
8
|
8
|
|
|
8
|
|
41
|
use warnings; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
235
|
|
9
|
8
|
|
|
8
|
|
14275
|
use Data::Dumper qw{Dumper}; |
|
8
|
|
|
|
|
131266
|
|
|
8
|
|
|
|
|
804
|
|
10
|
8
|
|
|
8
|
|
46382
|
use IO::File qw{}; |
|
8
|
|
|
|
|
125599
|
|
|
8
|
|
|
|
|
272
|
|
11
|
8
|
|
|
8
|
|
81
|
use Scalar::Util qw{blessed}; |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
924
|
|
12
|
8
|
|
|
8
|
|
68
|
use base qw{Exporter}; |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
5039
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @EXPORT = qw{DEBUG LOG}; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Hook into $SIG{__WARN__} if you want to route these debug messages |
18
|
|
|
|
|
|
|
# into your own logging system. |
19
|
|
|
|
|
|
|
BEGIN { |
20
|
8
|
|
|
8
|
|
91
|
my $log; |
21
|
|
|
|
|
|
|
|
22
|
8
|
50
|
33
|
|
|
62
|
if (exists $ENV{MCTEST} and $ENV{MCTEST}) { |
23
|
0
|
|
|
|
|
0
|
$ENV{MCDEBUG} = 1; |
24
|
0
|
0
|
|
|
|
0
|
open $log, ">>", ",,debug.log" or die "Couldn't open ,,debug.log"; |
25
|
0
|
|
|
|
|
0
|
$log->autoflush (1); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
8
|
50
|
|
|
|
39
|
if ($ENV{MCDEBUG}) { |
29
|
0
|
|
|
|
|
0
|
*DEBUG = sub () {1}; |
30
|
|
|
|
|
|
|
} else { |
31
|
8
|
|
|
|
|
25
|
*DEBUG = sub () {0}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
*LOG = sub (@) { |
35
|
0
|
|
|
0
|
|
|
local $Data::Dumper::Indent = 1; |
36
|
0
|
|
|
|
|
|
local $Data::Dumper::Quotekeys = 0; |
37
|
0
|
|
|
|
|
|
local $Data::Dumper::Sortkeys = 1; |
38
|
0
|
|
|
|
|
|
local $Data::Dumper::Terse = 1; |
39
|
0
|
0
|
|
|
|
|
my $format = shift or return; |
40
|
|
|
|
|
|
|
chomp (my $entry = @_ ? sprintf $format, map { |
41
|
0
|
0
|
|
|
|
|
if (defined $_) { |
|
0
|
0
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
if (ref $_) { |
43
|
0
|
0
|
0
|
|
|
|
if (blessed $_ and $_->can ('as_string')) { |
44
|
0
|
|
|
|
|
|
$_->as_string; |
45
|
|
|
|
|
|
|
} else { |
46
|
0
|
|
|
|
|
|
Dumper $_; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} else { |
49
|
0
|
|
|
|
|
|
$_ |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} else { |
52
|
0
|
|
|
|
|
|
'[undef]' |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} @_ : $format); |
55
|
|
|
|
|
|
|
# my $output = "$callerinfo[3] $entry\n"; |
56
|
0
|
|
|
|
|
|
my $output = "$entry\n"; |
57
|
0
|
0
|
|
|
|
|
if ($ENV{MCTEST}) { |
58
|
0
|
|
|
|
|
|
$log->print ($output); |
59
|
|
|
|
|
|
|
} else { |
60
|
0
|
|
|
|
|
|
warn $output; |
61
|
|
|
|
|
|
|
} |
62
|
8
|
|
|
|
|
302
|
}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |