ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/lib/AnyEvent/Log.pm
(Generate patch)

Comparing AnyEvent/lib/AnyEvent/Log.pm (file contents):
Revision 1.47 by root, Sun Mar 11 20:39:10 2012 UTC vs.
Revision 1.48 by root, Thu Mar 22 00:19:39 2012 UTC

9 use AnyEvent; 9 use AnyEvent;
10 10
11 AE::log trace => "going to call function abc"; 11 AE::log trace => "going to call function abc";
12 AE::log debug => "the function returned 3"; 12 AE::log debug => "the function returned 3";
13 AE::log info => "file soandso successfully deleted"; 13 AE::log info => "file soandso successfully deleted";
14 AE::log note => "wanted to create config, but config was alraedy created"; 14 AE::log note => "wanted to create config, but config was already created";
15 AE::log warn => "couldn't delete the file"; 15 AE::log warn => "couldn't delete the file";
16 AE::log error => "failed to retrieve data"; 16 AE::log error => "failed to retrieve data";
17 AE::log crit => "the battery temperature is too hot"; 17 AE::log crit => "the battery temperature is too hot";
18 AE::log alert => "the battery died"; 18 AE::log alert => "the battery died";
19 AE::log fatal => "no config found, cannot continue"; # never returns 19 AE::log fatal => "no config found, cannot continue"; # never returns
61attempt to be "the" logging solution or even "a" logging solution for 61attempt to be "the" logging solution or even "a" logging solution for
62AnyEvent - AnyEvent simply creates logging messages internally, and this 62AnyEvent - AnyEvent simply creates logging messages internally, and this
63module more or less exposes the mechanism, with some extra spiff to allow 63module more or less exposes the mechanism, with some extra spiff to allow
64using it from other modules as well. 64using it from other modules as well.
65 65
66Remember that the default verbosity level is C<0> (C<off>), so nothing 66Remember that the default verbosity level is C<3> (C<critical>), so little
67will be logged, unless you set C<PERL_ANYEVENT_VERBOSE> to a higher number 67will be logged, unless you set C<PERL_ANYEVENT_VERBOSE> to a higher number
68before starting your program, or change the logging level at runtime with 68before starting your program, or change the logging level at runtime with
69something like: 69something like:
70 70
71 use AnyEvent::Log; 71 use AnyEvent::Log;
106is the "official" name, the second one the "syslog" name (if it differs) 106is the "official" name, the second one the "syslog" name (if it differs)
107and the third one the "perl" name, suggesting (only!) that you log C<die> 107and the third one the "perl" name, suggesting (only!) that you log C<die>
108messages at C<error> priority. The NOTE column tries to provide some 108messages at C<error> priority. The NOTE column tries to provide some
109rationale on how to chose a logging level. 109rationale on how to chose a logging level.
110 110
111As a rough guideline, levels 1..3 are primarily meant for users of 111As a rough guideline, levels 1..3 are primarily meant for users of the
112the program (admins, staff), and are the only logged to STDERR by 112program (admins, staff), and are the only ones logged to STDERR by
113default. Levels 4..6 are meant for users and developers alike, while 113default. Levels 4..6 are meant for users and developers alike, while
114levels 7..9 are usually meant for developers. 114levels 7..9 are usually meant for developers.
115 115
116You can normally only log a single message at highest priority level 116You can normally only log a message once at highest priority level (C<1>,
117(C<1>, C<fatal>), because logging a fatal message will also quit the 117C<fatal>), because logging a fatal message will also quit the program - so
118program - so use it sparingly :) 118use it sparingly :)
119 119
120Some methods also offer some extra levels, such as C<0>, C<off>, C<none> 120Some methods also offer some extra levels, such as C<0>, C<off>, C<none>
121or C<all> - these are only valid in the methods they are documented for. 121or C<all> - these are only valid for the methods that documented them.
122 122
123=head1 LOGGING FUNCTIONS 123=head1 LOGGING FUNCTIONS
124 124
125These functions allow you to log messages. They always use the caller's 125The following functions allow you to log messages. They always use the
126package as a "logging context". Also, the main logging function C<log> is 126caller's package as a "logging context". Also, the main logging function,
127callable as C<AnyEvent::log> or C<AE::log> when the C<AnyEvent> module is 127C<log>, is aliased to C<AnyEvent::log> and C<AE::log> when the C<AnyEvent>
128loaded. 128module is loaded.
129 129
130=over 4 130=over 4
131 131
132=cut 132=cut
133 133

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines