NAME

Log::ger::Plugin::SingleLog - Create a log($LEVEL, ...) subroutine/method

VERSION

version 0.001

SYNOPSIS

use Log::ger::Plugin SingleLog => (
    sub_name => 'log',    # optional
    method_name => 'log', # optional
);
use Log::ger;

DESCRIPTION

The Log::ger way is to create separate log_XXX routine for each level, e.g. log_trace, log_warn, and so on. But sometimes you might want a single log routine that takes $level as the first argument, e.g. instead of:

log_warn('blah ...');

or:

$log->debug('Blah: %s', $data);

you prefer:

log('warn', 'blah ...');

or:

$log->log('debug', 'Blah: %s', $data);

This plugin can create such log routine for you.

Caveats:

  • Slower

    Using log($level, ...) is a bit slower (extra subroutine call, level parsing, and per-level dispatching).

  • The individual separate log_XXX subroutines/methods are still installed

SEE ALSO

Log::ger

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

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.