line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::Dispatch::Configurator::AppConfig; |
2
|
|
|
|
|
|
|
|
3
|
13
|
|
|
13
|
|
46777
|
use strict; |
|
13
|
|
|
|
|
29
|
|
|
13
|
|
|
|
|
670
|
|
4
|
13
|
|
|
13
|
|
78
|
use vars qw($VERSION); |
|
13
|
|
|
|
|
28
|
|
|
13
|
|
|
|
|
2063
|
|
5
|
|
|
|
|
|
|
$VERSION = '1.00'; |
6
|
|
|
|
|
|
|
|
7
|
13
|
|
|
13
|
|
7634
|
use Log::Dispatch::Configurator; |
|
13
|
|
|
|
|
39
|
|
|
13
|
|
|
|
|
432
|
|
8
|
13
|
|
|
13
|
|
101
|
use base qw(Log::Dispatch::Configurator); |
|
13
|
|
|
|
|
28
|
|
|
13
|
|
|
|
|
1557
|
|
9
|
13
|
|
|
13
|
|
256766
|
use AppConfig; |
|
13
|
|
|
|
|
130556
|
|
|
13
|
|
|
|
|
8031
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
14
|
|
|
14
|
0
|
9459
|
my($class, $file, $section) = @_; |
13
|
14
|
100
|
|
|
|
398
|
my $self = bless { section => ($section ? "${section}_" : '') }, $class; |
14
|
14
|
100
|
66
|
|
|
139
|
if(ref $file && $file->isa('AppConfig')){ |
15
|
1
|
|
|
|
|
10
|
$self->{config} = $file; |
16
|
|
|
|
|
|
|
}else{ |
17
|
13
|
|
|
|
|
133
|
$self->{file} = $file; |
18
|
|
|
|
|
|
|
} |
19
|
14
|
|
|
|
|
59
|
$self->parse_file; |
20
|
14
|
|
|
|
|
100
|
return $self; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub parse_file { |
24
|
17
|
|
|
17
|
0
|
103
|
my $self = shift; |
25
|
|
|
|
|
|
|
|
26
|
17
|
|
|
|
|
44
|
my $section = $self->{section}; |
27
|
17
|
|
|
|
|
29
|
my $config; |
28
|
17
|
100
|
|
|
|
83
|
if($self->{config}){ |
29
|
1
|
|
|
|
|
3
|
$config = $self->{config}; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
else{ |
32
|
16
|
|
|
|
|
164
|
$config = AppConfig->new({ |
33
|
|
|
|
|
|
|
CREATE => 1, |
34
|
|
|
|
|
|
|
GLOBAL => { |
35
|
|
|
|
|
|
|
ARGCOUNT => AppConfig::ARGCOUNT_ONE(), |
36
|
|
|
|
|
|
|
}, |
37
|
|
|
|
|
|
|
}); |
38
|
16
|
|
|
|
|
3427
|
$config->file($self->{file}); |
39
|
|
|
|
|
|
|
} |
40
|
17
|
100
|
|
|
|
87833
|
$config->define("${section}dispatchers" => { DEFAULT => '' }) unless $config->varlist("^${section}dispatchers\$"); |
41
|
17
|
50
|
|
|
|
1154
|
$config->define("${section}format" => { DEFAULT => undef }) unless $config->varlist("^${section}format\$"); |
42
|
|
|
|
|
|
|
|
43
|
17
|
|
|
|
|
1862
|
$self->{_config} = $config; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub reload { |
47
|
3
|
|
|
3
|
0
|
7
|
my $self = shift; |
48
|
3
|
|
|
|
|
35
|
$self->parse_file; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
60
|
|
|
60
|
|
9029
|
sub _config { $_[0]->{_config} } |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub get_attrs_global { |
54
|
17
|
|
|
17
|
0
|
38
|
my $self = shift; |
55
|
17
|
|
|
|
|
48
|
my $section = $self->{section}; |
56
|
|
|
|
|
|
|
return { |
57
|
17
|
|
|
|
|
68
|
format => scalar $self->_config->get("${section}format"), |
58
|
|
|
|
|
|
|
dispatchers => [ split /\s+/, $self->_config->get("${section}dispatchers") ], |
59
|
|
|
|
|
|
|
}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub get_attrs { |
63
|
26
|
|
|
26
|
0
|
57
|
my($self, $name) = @_; |
64
|
26
|
|
|
|
|
64
|
my $section = $self->{section}; |
65
|
26
|
|
|
|
|
88
|
my $regex = "^$section$name" . '[\._]'; |
66
|
26
|
|
|
|
|
81
|
my %var = $self->_config->varlist($regex); |
67
|
109
|
|
|
|
|
601
|
my %param = map { |
68
|
26
|
|
|
|
|
1627
|
(my $key = $_) =~ s/$regex//; |
69
|
109
|
|
|
|
|
422
|
$key => $var{$_}; |
70
|
|
|
|
|
|
|
} keys %var; |
71
|
26
|
|
|
|
|
232
|
return \%param; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
__END__ |