line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JLogger::Config; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
571
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
675
|
use YAML(); |
|
1
|
|
|
|
|
7610
|
|
|
1
|
|
|
|
|
297
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
1
|
|
|
1
|
0
|
415
|
bless {}, shift; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub load { |
13
|
1
|
|
|
1
|
0
|
521
|
my ($self, $config_text) = @_; |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
|
|
3
|
my $config = YAML::Load($config_text); |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
|
|
34800
|
$self->_fix_element($config, 'transport'); |
18
|
1
|
|
|
|
|
5
|
$self->_fix_elements($config, 'storages'); |
19
|
1
|
|
|
|
|
4
|
$self->_fix_elements($config, 'filters'); |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
5
|
$config; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub load_file { |
25
|
0
|
|
|
0
|
0
|
0
|
my ($self, $config_file) = @_; |
26
|
|
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
0
|
open my $fh, '<:encoding(UTF-8)', $config_file, |
28
|
|
|
|
|
|
|
or die qq(Can't open "$config_file": $!); |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
0
|
my $config_text = do { |
31
|
0
|
|
|
|
|
0
|
local $/; |
32
|
0
|
|
|
|
|
0
|
<$fh>; |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
0
|
close $fh; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
0
|
$self->load($config_text); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _fix_element { |
41
|
1
|
|
|
1
|
|
4
|
my ($self, $config, $element_key) = @_; |
42
|
|
|
|
|
|
|
|
43
|
1
|
50
|
|
|
|
11
|
$config->{$element_key} = |
44
|
|
|
|
|
|
|
$self->_fix_element_value($config->{$element_key}) |
45
|
|
|
|
|
|
|
if exists $config->{$element_key}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _fix_elements { |
49
|
2
|
|
|
2
|
|
4
|
my ($self, $config, $elements_key) = @_; |
50
|
|
|
|
|
|
|
|
51
|
2
|
50
|
|
|
|
7
|
if (exists $config->{$elements_key}) { |
52
|
2
|
|
|
|
|
3
|
$_ = $self->_fix_element_value($_) for @{$config->{$elements_key}}; |
|
2
|
|
|
|
|
10
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _fix_element_value { |
57
|
3
|
|
|
3
|
|
6
|
my ($self, $element) = @_; |
58
|
|
|
|
|
|
|
|
59
|
3
|
|
|
|
|
6
|
my $ref = ref $element; |
60
|
3
|
100
|
|
|
|
12
|
if ($ref eq '') { |
|
|
50
|
|
|
|
|
|
61
|
1
|
|
|
|
|
5
|
return [$element]; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
elsif ($ref eq 'HASH') { |
64
|
2
|
|
|
|
|
13
|
return [%$element]; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
$element; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |