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.4 by root, Wed Aug 17 02:50:35 2011 UTC vs.
Revision 1.5 by root, Wed Aug 17 22:03:03 2011 UTC

12attempt to be "the" logging solution or even "a" logging solution for 12attempt to be "the" logging solution or even "a" logging solution for
13AnyEvent - AnyEvent simply creates logging messages internally, and this 13AnyEvent - AnyEvent simply creates logging messages internally, and this
14module more or less exposes the mechanism, with some extra spiff to allow 14module more or less exposes the mechanism, with some extra spiff to allow
15using it from other modules as well. 15using it from other modules as well.
16 16
17Remember that the default verbosity level is C<0>, so nothing 17Remember that the default verbosity level is C<0>, so nothing will be
18will be logged, ever, unless you set C<$Anyvent::VERBOSE> or 18logged, ever, unless you set C<PERL_ANYEVENT_VERBOSE> to a higher number
19C<PERL_ANYEVENT_VERBOSE> to a higher number. 19before starting your program.#TODO
20 20
21Possible future extensions are to allow custom log targets (where the 21Possible future extensions are to allow custom log targets (where the
22level is an object), log filtering based on package, formatting, aliasing 22level is an object), log filtering based on package, formatting, aliasing
23or package groups. 23or package groups.
24 24
52 if $now_int != $i; 52 if $now_int != $i;
53 53
54 "$now_str1$f$now_str2" 54 "$now_str1$f$now_str2"
55} 55}
56 56
57our %CFG; #TODO 57our %CTX; # all logging contexts
58 58
59=item AnyEvent::Log::log $level, $msg[, @args] 59=item AnyEvent::Log::log $level, $msg[, @args]
60 60
61Requests logging of the given C<$msg> with the given log level (1..9). 61Requests logging of the given C<$msg> with the given log level (1..9).
62You can also use the following strings as log level: C<fatal> (1), 62You can also use the following strings as log level: C<fatal> (1),
254 254
255None, yet, except for C<PERL_ANYEVENT_VERBOSE>, described in the L<AnyEvent> manpage. 255None, yet, except for C<PERL_ANYEVENT_VERBOSE>, described in the L<AnyEvent> manpage.
256 256
257=over 4 257=over 4
258 258
259=item $ctx = AnyEvent::Log::ctx [$pkg]
260
261Returns the I<context> object for the given package name (or previously
262created package-less context). If no package name, or C<undef>, is given,
263then it creates a new anonymous context that is not tied to any package.
264
259=cut 265=cut
266
267sub ctx(;$) {
268 my $name = shift;
269
270 my $ctx = defined $name ? $CTX{$name} : undef;
271
272 unless ($ctx} {
273 $ctx = bless {}, "AnyEvent::Log::Ctx";
274 $name = $ctx+0 unless defined $name;
275 $CTX{
276
277 if (defined $name) {
278 my $ctx = {};
279 $CTX{$ctx+0} = $ctx;
280 } else {
281 $CTX{
282 }
283}
260 284
2611; 2851;
262 286
263=back 287=back
264 288

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines