Filename | /usr/local/src/github.com/foswiki/core/lib/Foswiki/Logger.pm |
Statements | Executed 8 statements in 384µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 28µs | 35µs | BEGIN@4 | Foswiki::Logger::
1 | 1 | 1 | 19µs | 63µs | BEGIN@7 | Foswiki::Logger::
1 | 1 | 1 | 16µs | 34µs | BEGIN@5 | Foswiki::Logger::
1 | 1 | 1 | 8µs | 8µs | finish | Foswiki::Logger::
0 | 0 | 0 | 0s | 0s | eachEventSince | Foswiki::Logger::
0 | 0 | 0 | 0s | 0s | log | Foswiki::Logger::
0 | 0 | 0 | 0s | 0s | new | Foswiki::Logger::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | package Foswiki::Logger; | ||||
3 | |||||
4 | 2 | 44µs | 2 | 43µs | # spent 35µs (28+7) within Foswiki::Logger::BEGIN@4 which was called:
# once (28µs+7µs) by Foswiki::BEGIN@606 at line 4 # spent 35µs making 1 call to Foswiki::Logger::BEGIN@4
# spent 7µs making 1 call to strict::import |
5 | 2 | 89µs | 2 | 53µs | # spent 34µs (16+19) within Foswiki::Logger::BEGIN@5 which was called:
# once (16µs+19µs) by Foswiki::BEGIN@606 at line 5 # spent 34µs making 1 call to Foswiki::Logger::BEGIN@5
# spent 19µs making 1 call to warnings::import |
6 | |||||
7 | 2 | 237µs | 2 | 107µs | # spent 63µs (19+44) within Foswiki::Logger::BEGIN@7 which was called:
# once (19µs+44µs) by Foswiki::BEGIN@606 at line 7 # spent 63µs making 1 call to Foswiki::Logger::BEGIN@7
# spent 44µs making 1 call to Assert::import |
8 | |||||
9 | =begin TML | ||||
10 | |||||
11 | ---+ package Foswiki::Logger | ||||
12 | |||||
13 | Object that interfaces to whatever records Foswiki log files. | ||||
14 | |||||
15 | This is a base class which will be subclassed by a class in the | ||||
16 | Logger subdirectory and selected by $Foswiki::cfg{Log}{Implementation} | ||||
17 | |||||
18 | Note that the implementation has to provide a way for the log to be replayed. | ||||
19 | Unfortunately this means that the simpler CPAN loggers are not suitable. | ||||
20 | |||||
21 | =cut | ||||
22 | |||||
23 | sub new { | ||||
24 | return bless( {}, shift ); | ||||
25 | } | ||||
26 | |||||
27 | =begin TML | ||||
28 | |||||
29 | ---++ ObjectMethod finish() | ||||
30 | Release memory. Subclasses must implement this if they use any fields | ||||
31 | in the object. | ||||
32 | |||||
33 | =cut | ||||
34 | |||||
35 | # spent 8µs within Foswiki::Logger::finish which was called:
# once (8µs+0s) by Foswiki::finish at line 2100 of /usr/local/src/github.com/foswiki/core/lib/Foswiki.pm | ||||
36 | 1 | 10µs | my $this = shift; | ||
37 | } | ||||
38 | |||||
39 | =begin TML | ||||
40 | |||||
41 | ---++ ObjectMethod log($level, @fields) | ||||
42 | |||||
43 | Adds a log message to a log. | ||||
44 | |||||
45 | * =$level= - level of the event - one of =debug=, =info=, | ||||
46 | =warning=, =error=, =critical=, =alert=, =emergency=. | ||||
47 | * =@fields= - an arbitrary list of fields to output to the log. | ||||
48 | These fields are recoverable when the log is enumerated using the | ||||
49 | =eachEventSince= method. | ||||
50 | |||||
51 | The levels are chosen to be compatible with Log::Dispatch. | ||||
52 | |||||
53 | =cut | ||||
54 | |||||
55 | # Default behaviour is a NOP | ||||
56 | sub log { | ||||
57 | } | ||||
58 | |||||
59 | =begin TML | ||||
60 | |||||
61 | ---++ ObjectMethod eachEventSince($time, $level) -> $iterator | ||||
62 | * =$time= - a time in the past | ||||
63 | * =$level= - log level to return events for. | ||||
64 | |||||
65 | Get an iterator over the list of all the events at the given level | ||||
66 | between =$time= and now. | ||||
67 | |||||
68 | Events are returned in *oldest-first* order. | ||||
69 | |||||
70 | Each event is returned as a reference to an array. The first element | ||||
71 | of this array is always the date of the event (seconds since the epoch). | ||||
72 | Subsequent elements are the fields passed to =log=. | ||||
73 | |||||
74 | Note that a log implementation may choose to collapse several log levels | ||||
75 | into a single log. In this case, all messages in the same set as the | ||||
76 | requested level will be returned if any of the collapsed levels is selected. | ||||
77 | |||||
78 | =cut | ||||
79 | |||||
80 | # Default behaviour is an empty iteration | ||||
81 | sub eachEventSince { | ||||
82 | return new Foswiki::ListIterator( [] ); | ||||
83 | } | ||||
84 | |||||
85 | 1 | 4µs | 1; | ||
86 | __END__ |