Log::ger::Plugin::Multisets - Create multiple sets of logger routines, each set with its own init arguments
version 0.005
Instead of having to resort to OO style to log to different categories:
use Log::ger (); my $access_log = Log::ger->get_logger(category => 'access'); my $error_log = Log::ger->get_logger(category => 'error'); $access_log->info ("goes to access log"); $access_log->warn ("goes to access log"); $error_log ->warn ("goes to error log"); $error_log ->debug("goes to error log"); ...
you can instead:
use Log::ger::Plugin Multisets => ( logger_sub_prefixes => { # prefix => per-target conf log_ => {category=>'error' }, # or undef, to use the default init args (including category) access_ => {category=>'access'}, }, level_checker_sub_prefixes => { # prefix => per-target conf is_ => {category=>'error' }, access_is_ => {category=>'access'}, }, ); use Log::ger; log_warn "goes to error log"; # a logger sub for the 'error' category, using the "log_" prefix log_debug "goes to error log"; # another access_info "goes to access log"; # a logger sub for the 'access' category, using the "access_" prefix access_warn "goes to access log"; # another if (is_debug()) { ... } # a level checker sub for the 'error' category, using the "is_" prefix if (access_is_trace()) { ... } # a level checker sub for the 'access' category, using the "access_is_" prefix
This plugin lets you create multiple sets of logger subroutines, each set with its own init arguments. This can be used e.g. when you want to log to different categories without resorting to OO style.
Hash.
Log::ger
perlancar <perlancar@cpan.org>
This software is copyright (c) 2022, 2020 by perlancar <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::Plugin::Multisets, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Log::ger::Plugin::Multisets
CPAN shell
perl -MCPAN -e shell install Log::ger::Plugin::Multisets
For more information on module installation, please visit the detailed CPAN module installation guide.