Filename | /var/www/foswiki11/lib/Foswiki/Logger.pm |
Statements | Executed 7 statements in 183µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 15µs | 32µs | BEGIN@4 | Foswiki::Logger::
1 | 1 | 1 | 11µs | 18µs | BEGIN@5 | Foswiki::Logger::
1 | 1 | 1 | 9µs | 23µs | BEGIN@7 | 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 | 42µs | 2 | 50µs | # spent 32µs (15+18) within Foswiki::Logger::BEGIN@4 which was called:
# once (15µs+18µs) by Foswiki::BEGIN@629 at line 4 # spent 32µs making 1 call to Foswiki::Logger::BEGIN@4
# spent 18µs making 1 call to strict::import |
5 | 2 | 27µs | 2 | 24µs | # spent 18µs (11+6) within Foswiki::Logger::BEGIN@5 which was called:
# once (11µs+6µs) by Foswiki::BEGIN@629 at line 5 # spent 18µs making 1 call to Foswiki::Logger::BEGIN@5
# spent 6µs making 1 call to warnings::import |
6 | |||||
7 | 2 | 111µs | 2 | 37µs | # spent 23µs (9+14) within Foswiki::Logger::BEGIN@7 which was called:
# once (9µs+14µs) by Foswiki::BEGIN@629 at line 7 # spent 23µs making 1 call to Foswiki::Logger::BEGIN@7
# spent 14µ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 log($level, @fields) | ||||
30 | |||||
31 | Adds a log message to a log. | ||||
32 | |||||
33 | * =$level= - level of the event - one of =debug=, =info=, | ||||
34 | =warning=, =error=, =critical=, =alert=, =emergency=. | ||||
35 | * =@fields= - an arbitrary list of fields to output to the log. | ||||
36 | These fields are recoverable when the log is enumerated using the | ||||
37 | =eachEventSince= method. | ||||
38 | |||||
39 | The levels are chosen to be compatible with Log::Dispatch. | ||||
40 | |||||
41 | =cut | ||||
42 | |||||
43 | # Default behaviour is a NOP | ||||
44 | sub log { | ||||
45 | } | ||||
46 | |||||
47 | =begin TML | ||||
48 | |||||
49 | ---++ ObjectMethod eachEventSince($time, $level) -> $iterator | ||||
50 | * =$time= - a time in the past | ||||
51 | * =$level= - log level to return events for. | ||||
52 | |||||
53 | Get an iterator over the list of all the events at the given level | ||||
54 | between =$time= and now. | ||||
55 | |||||
56 | Events are returned in *oldest-first* order. | ||||
57 | |||||
58 | Each event is returned as a reference to an array. The first element | ||||
59 | of this array is always the date of the event (seconds since the epoch). | ||||
60 | Subsequent elements are the fields passed to =log=. | ||||
61 | |||||
62 | Note that a log implementation may choose to collapse several log levels | ||||
63 | into a single log. In this case, all messages in the same set as the | ||||
64 | requested level will be returned if any of the collapsed levels is selected. | ||||
65 | |||||
66 | =cut | ||||
67 | |||||
68 | # Default behaviour is an empty iteration | ||||
69 | sub eachEventSince { | ||||
70 | require Foswiki::ListIterator; | ||||
71 | return new Foswiki::ListIterator( [] ); | ||||
72 | } | ||||
73 | |||||
74 | 1 | 2µs | 1; | ||
75 | __END__ |