Log::ger::Plugin::MultilevelLog - Create a log($LEVEL, ...) subroutine/method
version 0.014
use Log::ger::Plugin MultilevelLog => ( sub_name => 'log', # optional method_name => 'log', # optional ); use Log::ger;
The default way is to create separate log_LEVEL subroutine (or LEVEL methods) for each level, e.g. log_trace subroutine (or trace method), log_warn (or warn), and so on. But sometimes you might want a log routine that takes $level as the first argument, e.g. instead of:
log_LEVEL
LEVEL
log_trace
trace
log_warn
warn
log_warn('blah ...');
or:
$log->debug('Blah: %s', $data);
you prefer:
log('warn', 'blah ...');
$log->log('debug', 'Blah: %s', $data);
This plugin can create such log routine for you.
Note: the multilevel log is slower because of extra argument and additional string level -> numeric level conversion.
Note: the individual separate log_LEVEL subroutines (or LEVEL methods) are still installed.
perlancar <perlancar@cpan.org>
This software is copyright (c) 2017 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Log::ger, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Log::ger
CPAN shell
perl -MCPAN -e shell install Log::ger
For more information on module installation, please visit the detailed CPAN module installation guide.