line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Narada::Log; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
2979067
|
use warnings; |
|
4
|
|
|
|
|
40
|
|
|
4
|
|
|
|
|
291
|
|
4
|
4
|
|
|
4
|
|
38
|
use strict; |
|
4
|
|
|
|
|
28
|
|
|
4
|
|
|
|
|
187
|
|
5
|
4
|
|
|
4
|
|
41
|
use Carp; |
|
4
|
|
|
|
|
19
|
|
|
4
|
|
|
|
|
721
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = 'v2.3.8'; |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
1521
|
use Narada::Config qw( get_config_line ); |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
17
|
|
10
|
4
|
|
|
4
|
|
5249
|
use Log::Fast; |
|
4
|
|
|
|
|
76122
|
|
|
4
|
|
|
|
|
252
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
_init_log(); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub import { |
17
|
4
|
|
|
4
|
|
40
|
my @args = @_; |
18
|
4
|
|
|
|
|
22
|
my $pkg = caller 0; |
19
|
4
|
|
|
4
|
|
36
|
no strict 'refs'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
997
|
|
20
|
4
|
|
|
|
|
90
|
for (@args) { |
21
|
7
|
100
|
|
|
|
25
|
if (m/\A\$(.*)/xms) { |
22
|
3
|
|
|
|
|
12
|
*{$pkg.q{::}.$1} = \Log::Fast->global(); |
|
3
|
|
|
|
|
37
|
|
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
4
|
|
|
|
|
4237
|
return; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _init_log { |
29
|
4
|
|
50
|
4
|
|
7
|
my $type = eval { get_config_line('log/type') } || 'syslog'; |
30
|
4
|
|
50
|
|
|
8
|
my $path = eval { get_config_line('log/output') } || return; |
31
|
4
|
50
|
|
|
|
21
|
if ($type eq 'syslog') { |
|
|
50
|
|
|
|
|
|
32
|
0
|
|
|
|
|
0
|
Log::Fast->global()->config({ |
33
|
|
|
|
|
|
|
level => get_config_line('log/level'), |
34
|
|
|
|
|
|
|
prefix => q{}, |
35
|
|
|
|
|
|
|
type => 'unix', |
36
|
|
|
|
|
|
|
path => $path, |
37
|
|
|
|
|
|
|
}); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
elsif ($type eq 'file') { |
40
|
4
|
50
|
|
|
|
272
|
open my $fh, '>>', $path or croak "open: $!"; ## no critic (InputOutput::RequireBriefOpen) |
41
|
4
|
|
|
|
|
40
|
Log::Fast->global()->config({ |
42
|
|
|
|
|
|
|
level => get_config_line('log/level'), |
43
|
|
|
|
|
|
|
prefix => q{}, |
44
|
|
|
|
|
|
|
type => 'fh', |
45
|
|
|
|
|
|
|
fh => $fh, |
46
|
|
|
|
|
|
|
}); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
0
|
|
|
|
|
0
|
croak "Unsupported value '$type' in config/log/type"; |
50
|
|
|
|
|
|
|
} |
51
|
4
|
|
|
|
|
4086
|
return; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
56
|
|
|
|
|
|
|
__END__ |