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.15 by root, Sat Aug 20 02:16:59 2011 UTC vs.
Revision 1.16 by root, Sat Aug 20 02:19:18 2011 UTC

20 $tracer->("i am here") if $trace; 20 $tracer->("i am here") if $trace;
21 $tracer->(sub { "lots of data: " . Dumper $self }) if $trace; 21 $tracer->(sub { "lots of data: " . Dumper $self }) if $trace;
22 22
23 # configuration 23 # configuration
24 24
25 # set logging for this package to maximum 25 # set logging for this package to errors and higher only
26 AnyEvent::Log::ctx->level ("all"); 26 AnyEvent::Log::ctx->level ("error");
27 27
28 # set logging globally to anything below debug 28 # set logging globally to anything below debug
29 (AnyEvent::Log::ctx "")->level ("notice"); 29 $AnyEvent::Log::Root->level ("notice");
30 30
31 # see also EXAMPLES, below 31 # see also EXAMPLES, below
32
33 # disable logging for package "AnyEvent" and all packages below it
34 AnyEvent->AnyEvent::Log::ctx->level (0);
35
36 # log everything below debug to a file, for the whole program
37 my $ctx = AnyEvent::Log::ctx;
38 $ctx->log_cb (sub { print FILE shift; 0 });
39 (AnyEvent::Log::ctx "")->add ($ctx);
40 32
41=head1 DESCRIPTION 33=head1 DESCRIPTION
42 34
43This module implements a relatively simple "logging framework". It doesn't 35This module implements a relatively simple "logging framework". It doesn't
44attempt to be "the" logging solution or even "a" logging solution for 36attempt to be "the" logging solution or even "a" logging solution for
280 # and later in your program 272 # and later in your program
281 $debug_log->("yo, stuff here") if $debug; 273 $debug_log->("yo, stuff here") if $debug;
282 274
283 $debug and $debug_log->("123"); 275 $debug and $debug_log->("123");
284 276
285Note: currently the enabled var is always true - that will be fixed in a
286future version :)
287
288=cut 277=cut
289 278
290our %LOGGER; 279our %LOGGER;
291 280
292# re-assess logging status for all loggers 281# re-assess logging status for all loggers
456 : bless [undef, (1 << 10) - 1 - 1], "AnyEvent::Log::Ctx" 445 : bless [undef, (1 << 10) - 1 - 1], "AnyEvent::Log::Ctx"
457} 446}
458 447
459=item AnyEvent::Log::reset 448=item AnyEvent::Log::reset
460 449
461Resets all package contexts contexts and recreates the default hierarchy 450Resets all package contexts and recreates the default hierarchy if
462if necessary, i.e. resets the logging subsystem to defaults. 451necessary, i.e. resets the logging subsystem to defaults, as much as
452possible. This process keeps references to contexts held by other parts of
453the program intact.
463 454
464This can be used to implement config-file (re-)loading: before loading a 455This can be used to implement config-file (re-)loading: before loading a
465configuration, reset all contexts. 456configuration, reset all contexts.
466
467Note that this currently destroys all logger callbacks - bug me if you
468need this fixed :)
469 457
470=cut 458=cut
471 459
472sub reset { 460sub reset {
473 # hard to kill complex data structures 461 # hard to kill complex data structures

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines