line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Narada::Log; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
2580399
|
use warnings; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
220
|
|
4
|
4
|
|
|
4
|
|
34
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
118
|
|
5
|
4
|
|
|
4
|
|
30
|
use Carp; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
521
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = 'v2.3.6'; |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
1856
|
use Narada::Config qw( get_config_line ); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
18
|
|
10
|
4
|
|
|
4
|
|
4587
|
use Log::Fast; |
|
4
|
|
|
|
|
63768
|
|
|
4
|
|
|
|
|
266
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
_init_log(); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub import { |
17
|
4
|
|
|
4
|
|
39
|
my @args = @_; |
18
|
4
|
|
|
|
|
19
|
my $pkg = caller 0; |
19
|
4
|
|
|
4
|
|
27
|
no strict 'refs'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
1001
|
|
20
|
4
|
|
|
|
|
81
|
for (@args) { |
21
|
7
|
100
|
|
|
|
29
|
if (m/\A\$(.*)/xms) { |
22
|
3
|
|
|
|
|
11
|
*{$pkg.q{::}.$1} = \Log::Fast->global(); |
|
3
|
|
|
|
|
39
|
|
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
4
|
|
|
|
|
3654
|
return; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _init_log { |
29
|
4
|
|
50
|
4
|
|
9
|
my $type = eval { get_config_line('log/type') } || 'syslog'; |
30
|
4
|
|
50
|
|
|
65
|
my $path = eval { get_config_line('log/output') } || return; |
31
|
4
|
50
|
|
|
|
20
|
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
|
|
|
|
392
|
open my $fh, '>>', $path or croak "open: $!"; ## no critic (InputOutput::RequireBriefOpen) |
41
|
4
|
|
|
|
|
24
|
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
|
|
|
|
|
3538
|
return; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
56
|
|
|
|
|
|
|
__END__ |