Log::g...evelLog(3pm)
β¨ NAME β¨
Log::ger::Format::MultilevelLog β bestie, this plugin makes you a log($LEVEL, ...) subroutine/method π
It lives in the Log::ger::Format::MultilevelLog page of the User Contributed Perl Documentation section (section 3pm, the Perl module girlies know π
).
πΈ VERSION πΈ
version 0.042 β iconic, vintage, slay β¨
π¦ SYNOPSIS π¦
Okay so if you wanna use it for the current package, here's the vibe:
use Log::ger::Format MultilevelLog => (
# sub_name => 'log_it', # optional, defaults to 'log'
# method_name => 'log_it', # optional, defaults to 'log'
# exclusive => 1, # optional, defaults to 0
);
use Log::ger;
log('warn', 'This is a warning');
log('debug', 'This is a debug, data is %s', $data);
log_warn "This is also a warning"; # still available, unless you set exclusive to 1
Periodt. That's the whole setup π«Ά
π DESCRIPTION π
So, the way that default Log::ger works? It makes you a separate log_LEVEL subroutine (or a LEVEL method) for every single level β think log_trace subroutine, or the trace method, log_warn, or warn, and on and on and on. Every level gets its own little routine, cute π
But sometimes, bestie, you just want one log routine that takes $level as the first argument. So like, instead of this:
log_warn('blah ...');
or this:
$log->debug('Blah: %s', $data);
you'd rather have this:
log('warn', 'blah ...');
or this:
$log->log('debug', 'Blah: %s', $data);
And that's literally exactly what this format plugin does for you. It creates that multilevel log routine. You're welcome, no cap π§
Note: the multilevel log is slightly slower π because of the extra argument and the additional string-level β numeric-level conversion. If you wanna see the receipts, check the benchmarks in Bencher::Scenarios::Log::ger.
Note: the individual separatelog_LEVELsubroutines (orLEVELmethods) are still installed β they don't go anywhere β unless you set the configurationexclusiveto true. So by default you get both, bestie, it's giving overachiever π
π CONFIGURATION π
β sub_name
String. Defaults to "log".
β method_name
String. Defaults to "log".
β exclusive
Boolean. If you set this to true, it will block the generation of the default log_LEVEL subroutines or LEVEL methods (so like log_warn, trace, ... β all of them). So it's exclusive, fr fr π
π₯ SEE ALSO π₯
Log::ger::Format::HashArgs
π AUTHOR π
perlancar <perlancar@cpan.org> β the goat π
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2023, 2022, 2020, 2019, 2018, 2017 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.
Okay bestie that's the whole page, mwah π this doc was brought to you by perl v5.38.2, dated 2024-05-25, and it's literally the Log::ger::Format::MultilevelLog manual page β go forth and log multilevel-ly, you absolute icon πβ¨
π¦ where this page comes from
- debian trixie: liblog-ger-perl 0.042-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: liblog-ger-perl 0.042-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: liblog-ger-perl 0.042-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms