Net::C...Logger(3pm)
π Net::C...Logger π
the manual page for Net::CLI::Interact::Logger β part of the User Contributed Perl Documentation, bestie. it's giving β¨per-instance, multi-target logging, with categoriesβ¨ and honestly? obsessed.
πΈ NAME πΈ
Net::CLI::Interact::Logger β per-instance multi-target logging, with categories π
β¨ SYNOPSIS β¨
$logger->log($category, $level, @message);
that's it. that's the whole vibe. π«Ά
π¦ DESCRIPTION π¦
okay so this module is a generic logging service, built on top of Log::Dispatch but with extra options and config sprinkled on top, periodt.
here's the deal: log messages coming from your app get categorized, and every single category can be switched on or off by itself, and each one gets its own log level (like "emergency" all the way down to "debug"). and if you want, you can slap high resolution timestamps onto those messages too. iconic. β
π DEFAULT CONFIGURATION π
because it's based on Log::Dispatch::Config, this logger can have multiple targets, and each one gets configured with its own independent level threshold. no cap.
the overall default config? it prints log messages to the screen (console), with a minimum level of "debug". and each category (more on that below π) has its own log level too.
π¨ bestie listen β categories are arbitrary, so if a category isn't explicitly enabled or disabled, it's assumed to be disabled. if you wanna invent a brand new category for your app, literally just think of the name and start using it, with a$leveland@messageexactly like in the SYNOPSIS up there. go off. π
π INTERFACE π
π log( $category, $level, @message )
the combo of category + level is what decides whether the log messages get emitted to any of the log destinations. destinations get set with the "log_config" method, and categories get configured with the "log_flags" method. iykyk.
the @message list gets joined by a space character, and a newline gets appended if the last message doesn't already contain one itself. then messages are prepended with the first character of their $category, and indented proportionally to their $level. the way that it formats... π
π§ log_config( %config )
this takes a "Log::Dispatch::Config" configuration (a hash ref, bestie), which means multiple log targets can be specified with different minimum level thresholds. there's a default config that emits messages to your screen (console) with no minimum threshold:
{
dispatchers => ['screen'],
screen => {
class => 'Log::Dispatch::Screen',
min_level => 'debug',
},
};
slay. π«Ά
πΈ log_flags( @categories | %category_level_map )
you (yes, you) are expected to specify which log categories you care about, and at what levels. and here's the important bit: if a category gets used for logging in the app but was never specified, it's deemed disabled. so even though the default destination log level is "debug", no messages are emitted until a category is enabled. not a single one. π
in the array reference form, the list should contain category names, and they'll all be mapped to the "error" level:
$logger->log_flags([qw/
network
disk
io
cpu
/]);
in the hash reference form, the keys should be category names and the values are log levels from this list below β ordered so that each level "includes" the levels above it:
emergency
alert
critical
error
warning
notice
info
debug
for example:
$logger->log_flags({
network => 'info',
disk => 'debug',
io => 'critical',
cpu => 'debug',
});
messages at or above the specified level get passed on to the "Log::Dispatch" target, which may then specify its own overriding threshold. two thresholds, one message. main character energy. β¨
π₯ Net::CLI::Interact->default_log_categories() π₯
not a part of this class, okay, but it's the only way to retrieve a list of the current log categories used in the Net::CLI::Interact distribution source. and heads up: it does not take into account any log categories added by the user. sorry bestie, them's the rules. π
β log_stamp( $boolean )
enable (this is the default) or disable the display of high resolution interval timestamps with each log message. π
π log_category( $boolean )
enable (again, the default) or disable the display of the first letters of the category name with each log message. cute little initial, we love her. π
π¦ log_start( [$seconds, $microseconds] )
the time of the start for generating a time interval when logging stamps. it defaults to the result of "Time::HiRes::gettimeofday" at the point the module gets loaded, in list context. β±οΈ
π would_log( $category, $level )
returns True if, according to the current "log_flags", the given $category is enabled at or above the threshold of $level. otherwise it returns False. and note β the "Log::Dispatch" targets maintain their own thresholds as well. π
π reminder reminder: that "Log::Dispatch" threshold thing goes both ways, bestie. this method says yes, the target might still say no. keep it in mind. π
that's the whole page, angel. go log something gorgeous. π
this has been the Net::C...Logger page, from perl v5.36.0, dated 2023-10-28 β mwah, take care of her, she's iconic π β¨π
π¦ where this page comes from
- debian trixie: libnet-cli-interact-perl 2.400002-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libnet-cli-interact-perl 2.400002-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libnet-cli-interact-perl 2.400002-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libnet-cli-interact-perl 2.400002-1 Β· 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