You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Log::Log4perl has an :easy mode to help people easily get started with Log4perl. It has some caveats, but it is a lot easier to do:
use Log::Log4perl qw( :easy );
DEBUG "I'm debugging!";
Than it is to do:
use Log::Log4perl;
my$LOG = Log::Log4perl->get_logger();
$LOG->debug( "I'm debugging!" );
Log::Any is a bit easier still: We already have a shortcut for getting a logger:
use Log::Any qw( $LOG );
$LOG->debug( "I'm debugging!" );
die$LOG->ERROR( "Unable to do the thing: %s", $! );
But we have to remember about $LOG always. Instead, we could totally, on-demand, build a bunch of subroutines in the importing namespace that set the right category and use the formatting versions of the log methods (debugf() instead of just debug()) and return the formatted log message as expected. This way, using Log::Any requires less knowledge:
use Log::Any qw( :easy );
DEBUG "I'm debugging!";
die ERROR "Unable to do the thing: %s", $!;
We need to make sure this has the same (or similar) performance profile as the other ways, or else nobody will use it. We also likely need to do two flavors: One for the log4perl log levels, and one for the syslog log levels.
Log::Log4perl has an :easy mode to help people easily get started with Log4perl. It has some caveats, but it is a lot easier to do:
Than it is to do:
Log::Any is a bit easier still: We already have a shortcut for getting a logger:
But we have to remember about
$LOG
always. Instead, we could totally, on-demand, build a bunch of subroutines in the importing namespace that set the right category and use the formatting versions of the log methods (debugf()
instead of justdebug()
) and return the formatted log message as expected. This way, using Log::Any requires less knowledge:We need to make sure this has the same (or similar) performance profile as the other ways, or else nobody will use it. We also likely need to do two flavors: One for the log4perl log levels, and one for the syslog log levels.
We also need to be careful about just blindly using the package name as a category, as Log4perl also needs: https://metacpan.org/pod/distribution/Log-Log4perl/lib/Log/Log4perl.pm#Pitfalls-with-Categories.
The text was updated successfully, but these errors were encountered: