line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::StringFormatter; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
30171
|
use 5.008005; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
82
|
|
4
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
68
|
|
5
|
2
|
|
|
2
|
|
19
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
71
|
|
6
|
2
|
|
|
2
|
|
11
|
use base qw/Exporter/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
576
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = "0.02"; |
9
|
|
|
|
|
|
|
our @EXPORT = qw/stringf/; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub stringf { |
12
|
7
|
|
|
7
|
1
|
13263
|
my $message = ''; |
13
|
7
|
100
|
66
|
|
|
47
|
if ( @_ == 1 && defined $_[0]) { |
|
|
100
|
|
|
|
|
|
14
|
3
|
|
|
|
|
17
|
$message = '' . Log::StringFormatter::Dumper->new($_[0]); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
elsif ( @_ >= 2 ) { |
17
|
3
|
|
|
|
|
9
|
$message = sprintf(shift, map { Log::StringFormatter::Dumper->new($_) } @_); |
|
4
|
|
|
|
|
18
|
|
18
|
|
|
|
|
|
|
} |
19
|
7
|
|
|
|
|
48
|
return $message; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
1; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
package |
25
|
|
|
|
|
|
|
Log::StringFormatter::Dumper; |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
59
|
|
28
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
75
|
|
29
|
2
|
|
|
2
|
|
9
|
use base qw/Exporter/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
127
|
|
30
|
2
|
|
|
2
|
|
575946
|
use Data::Dumper; |
|
2
|
|
|
|
|
19326
|
|
|
2
|
|
|
|
|
183
|
|
31
|
2
|
|
|
2
|
|
21
|
use Scalar::Util qw/blessed/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
236
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
use overload |
34
|
2
|
|
|
|
|
20
|
'""' => \&stringfy, |
35
|
|
|
|
|
|
|
'0+' => \&numeric, |
36
|
2
|
|
|
2
|
|
20
|
fallback => 1; |
|
2
|
|
|
|
|
5
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub new { |
39
|
7
|
|
|
7
|
|
13
|
my ($class, $value) = @_; |
40
|
7
|
|
|
|
|
104
|
bless \$value, $class; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub stringfy { |
44
|
6
|
|
|
6
|
|
9
|
my $self = shift; |
45
|
6
|
|
|
|
|
11
|
my $value = $$self; |
46
|
6
|
100
|
33
|
|
|
44
|
if ( blessed($value) && (my $stringify = overload::Method( $value, '""' ) || overload::Method( $value, '0+' )) ) { |
|
|
|
66
|
|
|
|
|
47
|
1
|
|
|
|
|
2887
|
$value = $stringify->($value); |
48
|
|
|
|
|
|
|
} |
49
|
6
|
|
|
|
|
129
|
dumper($value); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub numeric { |
53
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
54
|
1
|
|
|
|
|
4
|
my $value = $$self; |
55
|
1
|
50
|
0
|
|
|
7
|
if ( blessed($value) && (my $numeric = overload::Method( $value, '0+' ) || overload::Method( $value, '""' )) ) { |
|
|
|
33
|
|
|
|
|
56
|
0
|
|
|
|
|
0
|
$value = $numeric->($value); |
57
|
|
|
|
|
|
|
} |
58
|
1
|
|
|
|
|
25
|
$value; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub dumper { |
62
|
6
|
|
|
6
|
|
9
|
my $value = shift; |
63
|
6
|
100
|
66
|
|
|
31
|
if ( defined $value && ref($value) ) { |
64
|
2
|
|
|
|
|
7
|
local $Data::Dumper::Terse = 1; |
65
|
2
|
|
|
|
|
6
|
local $Data::Dumper::Indent = 0; |
66
|
2
|
|
|
|
|
3
|
local $Data::Dumper::Sortkeys = 1; |
67
|
2
|
|
|
|
|
8
|
$value = Data::Dumper::Dumper($value); |
68
|
|
|
|
|
|
|
} |
69
|
6
|
|
|
|
|
210
|
$value; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
__END__ |