line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::ger::Format::Default; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
4
|
|
|
|
|
|
|
our $DATE = '2020-02-18'; # DATE |
5
|
|
|
|
|
|
|
our $DIST = 'Log-ger-Format-Default'; # DIST |
6
|
|
|
|
|
|
|
our $VERSION = '0.002'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
86097
|
use strict; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
31
|
|
9
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
242
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub get_hooks { |
12
|
1
|
|
|
1
|
0
|
13
|
my %conf = @_; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
return { |
15
|
|
|
|
|
|
|
create_formatter => [ |
16
|
|
|
|
|
|
|
__PACKAGE__, # key |
17
|
|
|
|
|
|
|
50, # priority |
18
|
|
|
|
|
|
|
sub { # hook |
19
|
2
|
|
|
2
|
|
1379
|
my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook" |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $formatter = |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# the default formatter is sprintf-style that dumps data |
25
|
|
|
|
|
|
|
# structures arguments as well as undef as ''. |
26
|
|
|
|
|
|
|
sub { |
27
|
1
|
50
|
|
|
|
930
|
return $_[0] if @_ < 2; |
28
|
1
|
|
|
|
|
3
|
my $fmt = shift; |
29
|
1
|
|
|
|
|
2
|
my @args; |
30
|
1
|
|
|
|
|
4
|
for (@_) { |
31
|
1
|
50
|
|
|
|
5
|
if (!defined($_)) { |
|
|
50
|
|
|
|
|
|
32
|
0
|
|
|
|
|
0
|
push @args, ''; |
33
|
|
|
|
|
|
|
} elsif (ref $_) { |
34
|
0
|
0
|
|
|
|
0
|
require Log::ger::Util unless $Log::ger::_dumper; |
35
|
0
|
|
|
|
|
0
|
push @args, Log::ger::Util::_dump($_); |
36
|
|
|
|
|
|
|
} else { |
37
|
1
|
|
|
|
|
3
|
push @args, $_; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
1
|
|
|
|
|
7
|
sprintf $fmt, @args; |
41
|
2
|
|
|
|
|
7
|
}; |
42
|
|
|
|
|
|
|
|
43
|
2
|
|
|
|
|
8
|
[$formatter]; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
8
|
}], |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
# ABSTRACT: Use default Log::ger formatting style |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |