Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Log/Log4perl/Filter.pm |
Statements | Executed 21 statements in 408µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 26µs | 26µs | BEGIN@5 | Log::Log4perl::Filter::
1 | 1 | 1 | 8µs | 63µs | BEGIN@9 | Log::Log4perl::Filter::
1 | 1 | 1 | 7µs | 9µs | BEGIN@6 | Log::Log4perl::Filter::
1 | 1 | 1 | 7µs | 7µs | BEGIN@10 | Log::Log4perl::Filter::
1 | 1 | 1 | 6µs | 17µs | BEGIN@7 | Log::Log4perl::Filter::
1 | 1 | 1 | 6µs | 32µs | BEGIN@12 | Log::Log4perl::Filter::
1 | 1 | 1 | 3µs | 3µs | reset | Log::Log4perl::Filter::
0 | 0 | 0 | 0s | 0s | by_name | Log::Log4perl::Filter::
0 | 0 | 0 | 0s | 0s | new | Log::Log4perl::Filter::
0 | 0 | 0 | 0s | 0s | ok | Log::Log4perl::Filter::
0 | 0 | 0 | 0s | 0s | register | Log::Log4perl::Filter::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | ################################################## | ||||
2 | package Log::Log4perl::Filter; | ||||
3 | ################################################## | ||||
4 | |||||
5 | 3 | 35µs | 1 | 26µs | # spent 26µs within Log::Log4perl::Filter::BEGIN@5 which was called:
# once (26µs+0s) by Log::Log4perl::Config::BEGIN@12 at line 5 # spent 26µs making 1 call to Log::Log4perl::Filter::BEGIN@5 |
6 | 3 | 20µs | 2 | 11µs | # spent 9µs (7+2) within Log::Log4perl::Filter::BEGIN@6 which was called:
# once (7µs+2µs) by Log::Log4perl::Config::BEGIN@12 at line 6 # spent 9µs making 1 call to Log::Log4perl::Filter::BEGIN@6
# spent 2µs making 1 call to strict::import |
7 | 3 | 16µs | 2 | 27µs | # spent 17µs (6+10) within Log::Log4perl::Filter::BEGIN@7 which was called:
# once (6µs+10µs) by Log::Log4perl::Config::BEGIN@12 at line 7 # spent 17µs making 1 call to Log::Log4perl::Filter::BEGIN@7
# spent 10µs making 1 call to warnings::import |
8 | |||||
9 | 3 | 20µs | 2 | 118µs | # spent 63µs (8+55) within Log::Log4perl::Filter::BEGIN@9 which was called:
# once (8µs+55µs) by Log::Log4perl::Config::BEGIN@12 at line 9 # spent 63µs making 1 call to Log::Log4perl::Filter::BEGIN@9
# spent 55µs making 1 call to Log::Log4perl::Level::import |
10 | 3 | 22µs | 1 | 7µs | # spent 7µs within Log::Log4perl::Filter::BEGIN@10 which was called:
# once (7µs+0s) by Log::Log4perl::Config::BEGIN@12 at line 10 # spent 7µs making 1 call to Log::Log4perl::Filter::BEGIN@10 |
11 | |||||
12 | 3 | 288µs | 2 | 57µs | # spent 32µs (6+26) within Log::Log4perl::Filter::BEGIN@12 which was called:
# once (6µs+26µs) by Log::Log4perl::Config::BEGIN@12 at line 12 # spent 32µs making 1 call to Log::Log4perl::Filter::BEGIN@12
# spent 26µs making 1 call to constant::import |
13 | |||||
14 | 1 | 500ns | our %FILTERS_DEFINED = (); | ||
15 | |||||
16 | ################################################## | ||||
17 | sub new { | ||||
18 | ################################################## | ||||
19 | my($class, $name, $action) = @_; | ||||
20 | |||||
21 | print "Creating filter $name\n" if _INTERNAL_DEBUG; | ||||
22 | |||||
23 | my $self = { name => $name }; | ||||
24 | bless $self, $class; | ||||
25 | |||||
26 | if(ref($action) eq "CODE") { | ||||
27 | # it's a code ref | ||||
28 | $self->{ok} = $action; | ||||
29 | } else { | ||||
30 | # it's something else | ||||
31 | die "Code for ($name/$action) not properly defined"; | ||||
32 | } | ||||
33 | |||||
34 | return $self; | ||||
35 | } | ||||
36 | |||||
37 | ################################################## | ||||
38 | sub register { # Register a filter by name | ||||
39 | # (Passed on to subclasses) | ||||
40 | ################################################## | ||||
41 | my($self) = @_; | ||||
42 | |||||
43 | by_name($self->{name}, $self); | ||||
44 | } | ||||
45 | |||||
46 | ################################################## | ||||
47 | sub by_name { # Get/Set a filter object by name | ||||
48 | ################################################## | ||||
49 | my($name, $value) = @_; | ||||
50 | |||||
51 | if(defined $value) { | ||||
52 | $FILTERS_DEFINED{$name} = $value; | ||||
53 | } | ||||
54 | |||||
55 | if(exists $FILTERS_DEFINED{$name}) { | ||||
56 | return $FILTERS_DEFINED{$name}; | ||||
57 | } else { | ||||
58 | return undef; | ||||
59 | } | ||||
60 | } | ||||
61 | |||||
62 | ################################################## | ||||
63 | # spent 3µs within Log::Log4perl::Filter::reset which was called:
# once (3µs+0s) by Log::Log4perl::Logger::reset at line 113 of Log/Log4perl/Logger.pm | ||||
64 | ################################################## | ||||
65 | 1 | 4µs | %FILTERS_DEFINED = (); | ||
66 | } | ||||
67 | |||||
68 | ################################################## | ||||
69 | sub ok { | ||||
70 | ################################################## | ||||
71 | my($self, %p) = @_; | ||||
72 | |||||
73 | print "Calling $self->{name}'s ok method\n" if _INTERNAL_DEBUG; | ||||
74 | |||||
75 | # Force filter classes to define their own | ||||
76 | # ok(). Exempt are only sub {..} ok functions, | ||||
77 | # defined in the conf file. | ||||
78 | die "This is to be overridden by the filter" unless | ||||
79 | defined $self->{ok}; | ||||
80 | |||||
81 | # What should we set the message in $_ to? The most logical | ||||
82 | # approach seems to be to concat all parts together. If some | ||||
83 | # filter wants to dissect the parts, it still can examine %p, | ||||
84 | # which gets passed to the subroutine and contains the chunks | ||||
85 | # in $p{message}. | ||||
86 | # Split because of CVS | ||||
87 | local($_) = join $ | ||||
88 | Log::Log4perl::JOIN_MSG_ARRAY_CHAR, @{$p{message}}; | ||||
89 | print "\$_ is '$_'\n" if _INTERNAL_DEBUG; | ||||
90 | |||||
91 | my $decision = $self->{ok}->(%p); | ||||
92 | |||||
93 | print "$self->{name}'s ok'ed: ", | ||||
94 | ($decision ? "yes" : "no"), "\n" if _INTERNAL_DEBUG; | ||||
95 | |||||
96 | return $decision; | ||||
97 | } | ||||
98 | |||||
99 | 1 | 2µs | 1; | ||
100 | |||||
101 | __END__ |