From: Meir G. <me...@gu...> - 2012-07-04 08:24:36
|
Dear logging folks, First thank you for a very useful and comprehensive logging package. I have though an issue with one passage in the documentation. In the CPAN page Log::Log4perl (Ver. 1.37) (http://search.cpan.org/~mschilli/Log-Log4perl-1.37/lib/Log/Log4perl.pm) one can read the following: Instead of calling the methods $logger->trace("..."); # Log a trace message ... (other variants deleted) you could also call the log() method with the appropriate level using the constants defined in Log::Log4perl::Level: use Log::Log4perl::Level; $logger->log($TRACE, "..."); ... (other variants deleted) But *** nobody does that, really ***. (my enhancement - MG) Neither does anyone need more logging levels than these predefined ones. If you think you do, I would suggest you look into steering your logging behavior via the category mechanism. Well, I found at least one use for the $logger->log() method: dynamic level logging. Take for example a "system()" call. It can return a number of exit codes by issuing something like «exit(0x2C);» command. I find it very convenient to segregate on the basis of the return code what logging level to assign to the log message upon returning: my %exit_level = ( 0 => $INFO, 1 => $WARN, 2 => $WARN, 4 => $ERROR, 0xFF => $FATAL, ); My %message = ( 0 => "Message 1", 1 => "..." ... ); my $result = system ('perl', 'my_script.pl, @args) >>= 8; $logger->log($exit_level{$result}, $message{$result}); So, I would recommend a change in the doc showing such an example. Meir |