Filename | /usr/local/lib/perl5/site_perl/Mail/SpamAssassin/Logger/Stderr.pm |
Statements | Executed 24 statements in 2.13ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 9.19ms | 15.9ms | BEGIN@37 | Mail::SpamAssassin::Logger::Stderr::
1 | 1 | 1 | 5.69ms | 6.76ms | BEGIN@38 | Mail::SpamAssassin::Logger::Stderr::
1 | 1 | 1 | 45µs | 55µs | BEGIN@32 | Mail::SpamAssassin::Logger::Stderr::
1 | 1 | 1 | 40µs | 40µs | new | Mail::SpamAssassin::Logger::Stderr::
1 | 1 | 1 | 23µs | 99µs | BEGIN@40 | Mail::SpamAssassin::Logger::Stderr::
1 | 1 | 1 | 20µs | 50µs | BEGIN@33 | Mail::SpamAssassin::Logger::Stderr::
1 | 1 | 1 | 19µs | 25µs | BEGIN@34 | Mail::SpamAssassin::Logger::Stderr::
1 | 1 | 1 | 18µs | 73µs | BEGIN@35 | Mail::SpamAssassin::Logger::Stderr::
1 | 1 | 1 | 8µs | 8µs | close_log | Mail::SpamAssassin::Logger::Stderr::
0 | 0 | 0 | 0s | 0s | log_message | Mail::SpamAssassin::Logger::Stderr::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # <@LICENSE> | ||||
2 | # Licensed to the Apache Software Foundation (ASF) under one or more | ||||
3 | # contributor license agreements. See the NOTICE file distributed with | ||||
4 | # this work for additional information regarding copyright ownership. | ||||
5 | # The ASF licenses this file to you under the Apache License, Version 2.0 | ||||
6 | # (the "License"); you may not use this file except in compliance with | ||||
7 | # the License. You may obtain a copy of the License at: | ||||
8 | # | ||||
9 | # http://www.apache.org/licenses/LICENSE-2.0 | ||||
10 | # | ||||
11 | # Unless required by applicable law or agreed to in writing, software | ||||
12 | # distributed under the License is distributed on an "AS IS" BASIS, | ||||
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
14 | # See the License for the specific language governing permissions and | ||||
15 | # limitations under the License. | ||||
16 | # </@LICENSE> | ||||
17 | |||||
18 | =head1 NAME | ||||
19 | |||||
20 | Mail::SpamAssassin::Logger::Stderr - log to standard error | ||||
21 | |||||
22 | =head1 SYNOPSIS | ||||
23 | |||||
24 | loadplugin Mail::SpamAssassin::Logger::Stderr | ||||
25 | |||||
26 | =head1 DESCRIPTION | ||||
27 | |||||
28 | =cut | ||||
29 | |||||
30 | package Mail::SpamAssassin::Logger::Stderr; | ||||
31 | |||||
32 | 2 | 57µs | 2 | 65µs | # spent 55µs (45+10) within Mail::SpamAssassin::Logger::Stderr::BEGIN@32 which was called:
# once (45µs+10µs) by Mail::SpamAssassin::Logger::BEGIN@72 at line 32 # spent 55µs making 1 call to Mail::SpamAssassin::Logger::Stderr::BEGIN@32
# spent 10µs making 1 call to strict::import |
33 | 2 | 51µs | 2 | 79µs | # spent 50µs (20+30) within Mail::SpamAssassin::Logger::Stderr::BEGIN@33 which was called:
# once (20µs+30µs) by Mail::SpamAssassin::Logger::BEGIN@72 at line 33 # spent 50µs making 1 call to Mail::SpamAssassin::Logger::Stderr::BEGIN@33
# spent 30µs making 1 call to warnings::import |
34 | 2 | 53µs | 2 | 30µs | # spent 25µs (19+6) within Mail::SpamAssassin::Logger::Stderr::BEGIN@34 which was called:
# once (19µs+6µs) by Mail::SpamAssassin::Logger::BEGIN@72 at line 34 # spent 25µs making 1 call to Mail::SpamAssassin::Logger::Stderr::BEGIN@34
# spent 6µs making 1 call to bytes::import |
35 | 2 | 55µs | 2 | 128µs | # spent 73µs (18+55) within Mail::SpamAssassin::Logger::Stderr::BEGIN@35 which was called:
# once (18µs+55µs) by Mail::SpamAssassin::Logger::BEGIN@72 at line 35 # spent 73µs making 1 call to Mail::SpamAssassin::Logger::Stderr::BEGIN@35
# spent 55µs making 1 call to re::import |
36 | |||||
37 | 2 | 875µs | 1 | 15.9ms | # spent 15.9ms (9.19+6.75) within Mail::SpamAssassin::Logger::Stderr::BEGIN@37 which was called:
# once (9.19ms+6.75ms) by Mail::SpamAssassin::Logger::BEGIN@72 at line 37 # spent 15.9ms making 1 call to Mail::SpamAssassin::Logger::Stderr::BEGIN@37 |
38 | 2 | 350µs | 1 | 6.76ms | # spent 6.76ms (5.69+1.08) within Mail::SpamAssassin::Logger::Stderr::BEGIN@38 which was called:
# once (5.69ms+1.08ms) by Mail::SpamAssassin::Logger::BEGIN@72 at line 38 # spent 6.76ms making 1 call to Mail::SpamAssassin::Logger::Stderr::BEGIN@38 |
39 | |||||
40 | 2 | 611µs | 2 | 176µs | # spent 99µs (23+76) within Mail::SpamAssassin::Logger::Stderr::BEGIN@40 which was called:
# once (23µs+76µs) by Mail::SpamAssassin::Logger::BEGIN@72 at line 40 # spent 99µs making 1 call to Mail::SpamAssassin::Logger::Stderr::BEGIN@40
# spent 76µs making 1 call to vars::import |
41 | 1 | 8µs | @ISA = (); | ||
42 | |||||
43 | # spent 40µs within Mail::SpamAssassin::Logger::Stderr::new which was called:
# once (40µs+0s) by Mail::SpamAssassin::BEGIN@69 at line 73 of Mail/SpamAssassin/Logger.pm | ||||
44 | 1 | 2µs | my $class = shift; | ||
45 | |||||
46 | 1 | 8µs | $class = ref($class) || $class; | ||
47 | 1 | 2µs | my $self = { }; | ||
48 | 1 | 2µs | bless ($self, $class); | ||
49 | |||||
50 | 1 | 2µs | my %params = @_; | ||
51 | 1 | 16µs | $self->{timestamp_fmt} = $params{timestamp_fmt}; | ||
52 | |||||
53 | 1 | 14µs | return($self); | ||
54 | } | ||||
55 | |||||
56 | sub log_message { | ||||
57 | my ($self, $level, $msg) = @_; | ||||
58 | |||||
59 | my $timestamp; | ||||
60 | my $fmt = $self->{timestamp_fmt}; | ||||
61 | if (!defined $fmt) { | ||||
62 | # default since 3.3.0 | ||||
63 | my $now = Time::HiRes::time; | ||||
64 | $timestamp = sprintf("%s:%06.3f", | ||||
65 | POSIX::strftime("%b %d %H:%M", localtime($now)), $now-int($now/60)*60); | ||||
66 | # Bug 6329: %e is not in a POSIX standard, use %d instead and edit | ||||
67 | local $1; $timestamp =~ s/^(\S+\s+)0/$1 /; | ||||
68 | } elsif ($fmt eq '') { | ||||
69 | $timestamp = ''; | ||||
70 | } else { | ||||
71 | $timestamp = POSIX::strftime($fmt, localtime(Time::HiRes::time)); | ||||
72 | } | ||||
73 | $timestamp .= ' ' if $timestamp ne ''; | ||||
74 | |||||
75 | my($nwrite) = syswrite(STDERR, sprintf("%s[%d] %s: %s\n", | ||||
76 | $timestamp, $$, $level, $msg)); | ||||
77 | defined $nwrite or warn "error writing to log file: $!"; | ||||
78 | } | ||||
79 | |||||
80 | # spent 8µs within Mail::SpamAssassin::Logger::Stderr::close_log which was called:
# once (8µs+0s) by Mail::SpamAssassin::Logger::close_log at line 360 of Mail/SpamAssassin/Logger.pm | ||||
81 | 1 | 13µs | my ($self) = @_; | ||
82 | } | ||||
83 | |||||
84 | 1 | 8µs | 1; |