Log::g...evelLog(3pm)

πŸ“¦
version 0.042 Β· 3 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

✨ 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 separate log_LEVEL subroutines (or LEVEL methods) are still installed β€” they don't go anywhere β€” unless you set the configuration exclusive to 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 🐐


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