Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Log/Log4perl/Config/BaseConfigurator.pm |
Statements | Executed 13 statements in 490µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 16µs | 24µs | BEGIN@3 | Log::Log4perl::Config::BaseConfigurator::
1 | 1 | 1 | 9µs | 67µs | BEGIN@5 | Log::Log4perl::Config::BaseConfigurator::
1 | 1 | 1 | 7µs | 9µs | BEGIN@4 | Log::Log4perl::Config::BaseConfigurator::
0 | 0 | 0 | 0s | 0s | file | Log::Log4perl::Config::BaseConfigurator::
0 | 0 | 0 | 0s | 0s | new | Log::Log4perl::Config::BaseConfigurator::
0 | 0 | 0 | 0s | 0s | parse | Log::Log4perl::Config::BaseConfigurator::
0 | 0 | 0 | 0s | 0s | parse_post_process | Log::Log4perl::Config::BaseConfigurator::
0 | 0 | 0 | 0s | 0s | text | Log::Log4perl::Config::BaseConfigurator::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Log::Log4perl::Config::BaseConfigurator; | ||||
2 | |||||
3 | 3 | 18µs | 2 | 32µs | # spent 24µs (16+8) within Log::Log4perl::Config::BaseConfigurator::BEGIN@3 which was called:
# once (16µs+8µs) by Log::Log4perl::Config::PropertyConfigurator::BEGIN@2 at line 3 # spent 24µs making 1 call to Log::Log4perl::Config::BaseConfigurator::BEGIN@3
# spent 8µs making 1 call to warnings::import |
4 | 3 | 18µs | 2 | 10µs | # spent 9µs (7+2) within Log::Log4perl::Config::BaseConfigurator::BEGIN@4 which was called:
# once (7µs+2µs) by Log::Log4perl::Config::PropertyConfigurator::BEGIN@2 at line 4 # spent 9µs making 1 call to Log::Log4perl::Config::BaseConfigurator::BEGIN@4
# spent 2µs making 1 call to strict::import |
5 | 3 | 441µs | 2 | 124µs | # spent 67µs (9+58) within Log::Log4perl::Config::BaseConfigurator::BEGIN@5 which was called:
# once (9µs+58µs) by Log::Log4perl::Config::PropertyConfigurator::BEGIN@2 at line 5 # spent 67µs making 1 call to Log::Log4perl::Config::BaseConfigurator::BEGIN@5
# spent 58µs making 1 call to constant::import |
6 | |||||
7 | 1 | 4µs | *eval_if_perl = \&Log::Log4perl::Config::eval_if_perl; | ||
8 | 1 | 3µs | *compile_if_perl = \&Log::Log4perl::Config::compile_if_perl; | ||
9 | 1 | 2µs | *leaf_path_to_hash = \&Log::Log4perl::Config::leaf_path_to_hash; | ||
10 | |||||
11 | ################################################ | ||||
12 | sub new { | ||||
13 | ################################################ | ||||
14 | my($class, %options) = @_; | ||||
15 | |||||
16 | my $self = { | ||||
17 | %options, | ||||
18 | }; | ||||
19 | |||||
20 | $self->file($self->{file}) if exists $self->{file}; | ||||
21 | $self->text($self->{text}) if exists $self->{text}; | ||||
22 | |||||
23 | bless $self, $class; | ||||
24 | } | ||||
25 | |||||
26 | ################################################ | ||||
27 | sub text { | ||||
28 | ################################################ | ||||
29 | my($self, $text) = @_; | ||||
30 | |||||
31 | # $text is an array of scalars (lines) | ||||
32 | if(defined $text) { | ||||
33 | if(ref $text eq "ARRAY") { | ||||
34 | $self->{text} = $text; | ||||
35 | } else { | ||||
36 | $self->{text} = [split "\n", $text]; | ||||
37 | } | ||||
38 | } | ||||
39 | |||||
40 | return $self->{text}; | ||||
41 | } | ||||
42 | |||||
43 | ################################################ | ||||
44 | sub file { | ||||
45 | ################################################ | ||||
46 | my($self, $filename) = @_; | ||||
47 | |||||
48 | open FILE, "<$filename" or die "Cannot open $filename ($!)"; | ||||
49 | $self->{text} = [<FILE>]; | ||||
50 | close FILE; | ||||
51 | } | ||||
52 | |||||
53 | ################################################ | ||||
54 | sub parse { | ||||
55 | ################################################ | ||||
56 | die __PACKAGE__ . "::parse() is a virtual method. " . | ||||
57 | "It must be implemented " . | ||||
58 | "in a derived class (currently: ", ref(shift), ")"; | ||||
59 | } | ||||
60 | |||||
61 | ################################################ | ||||
62 | sub parse_post_process { | ||||
63 | ################################################ | ||||
64 | my($self, $data, $leaf_paths) = @_; | ||||
65 | |||||
66 | # [ | ||||
67 | # 'category', | ||||
68 | # 'value', | ||||
69 | # 'WARN, Logfile' | ||||
70 | # ], | ||||
71 | # [ | ||||
72 | # 'appender', | ||||
73 | # 'Logfile', | ||||
74 | # 'value', | ||||
75 | # 'Log::Log4perl::Appender::File' | ||||
76 | # ], | ||||
77 | # [ | ||||
78 | # 'appender', | ||||
79 | # 'Logfile', | ||||
80 | # 'filename', | ||||
81 | # 'value', | ||||
82 | # 'test.log' | ||||
83 | # ], | ||||
84 | # [ | ||||
85 | # 'appender', | ||||
86 | # 'Logfile', | ||||
87 | # 'layout', | ||||
88 | # 'value', | ||||
89 | # 'Log::Log4perl::Layout::PatternLayout' | ||||
90 | # ], | ||||
91 | # [ | ||||
92 | # 'appender', | ||||
93 | # 'Logfile', | ||||
94 | # 'layout', | ||||
95 | # 'ConversionPattern', | ||||
96 | # 'value', | ||||
97 | # '%d %F{1} %L> %m %n' | ||||
98 | # ] | ||||
99 | |||||
100 | for my $path ( @{ Log::Log4perl::Config::leaf_paths( $data )} ) { | ||||
101 | |||||
102 | print "path=@$path\n" if _INTERNAL_DEBUG; | ||||
103 | |||||
104 | if(0) { | ||||
105 | } elsif( | ||||
106 | $path->[0] eq "appender" and | ||||
107 | $path->[2] eq "trigger" | ||||
108 | ) { | ||||
109 | my $ref = leaf_path_to_hash( $path, $data ); | ||||
110 | my $code = compile_if_perl( $$ref ); | ||||
111 | |||||
112 | if(_INTERNAL_DEBUG) { | ||||
113 | if($code) { | ||||
114 | print "Code compiled: $$ref\n"; | ||||
115 | } else { | ||||
116 | print "Not compiled: $$ref\n"; | ||||
117 | } | ||||
118 | } | ||||
119 | |||||
120 | $$ref = $code if defined $code; | ||||
121 | } elsif ( | ||||
122 | $path->[0] eq "filter" | ||||
123 | ) { | ||||
124 | # do nothing | ||||
125 | } elsif ( | ||||
126 | $path->[0] eq "appender" and | ||||
127 | $path->[2] eq "warp_message" | ||||
128 | ) { | ||||
129 | # do nothing | ||||
130 | } elsif ( | ||||
131 | $path->[0] eq "appender" and | ||||
132 | $path->[3] eq "cspec" or | ||||
133 | $path->[1] eq "cspec" | ||||
134 | ) { | ||||
135 | # could be either | ||||
136 | # appender appndr layout cspec | ||||
137 | # or | ||||
138 | # PatternLayout cspec U value ... | ||||
139 | # | ||||
140 | # do nothing | ||||
141 | } else { | ||||
142 | my $ref = leaf_path_to_hash( $path, $data ); | ||||
143 | |||||
144 | if(_INTERNAL_DEBUG) { | ||||
145 | print "Calling eval_if_perl on $$ref\n"; | ||||
146 | } | ||||
147 | |||||
148 | $$ref = eval_if_perl( $$ref ); | ||||
149 | } | ||||
150 | } | ||||
151 | |||||
152 | return $data; | ||||
153 | } | ||||
154 | |||||
155 | 1 | 4µs | 1; | ||
156 | |||||
157 | __END__ |