Log::Co...eLogger(3)
okay so bestie, welcome to the Log::Contextual::TeeLogger(3) page β and yes, itβs from the User Contributed Perl Documentation, with the manual name folded in right here at the top instead of that whole truncated header line. The vibes? Immaculate. The logger? A little demo-y. Letβs get into it. π«Ά
πΈ NAME πΈ
Log::Contextual::TeeLogger β output to more than one logger. Thatβs the whole name, and honestly? Iconic. π
β¨ VERSION β¨
version 0.009001 β noted, filed, and slaying. π
π§ SYNOPSIS π§
Hereβs the code, bestie β exactly as written, no cap:
use Log::Contextual::SimpleLogger;
use Log::Contextual::TeeLogger;
use Log::Contextual qw( :log ),
-logger => Log::Contextual::TeeLogger->new({ loggers => [
Log::Contextual::SimpleLogger->new({ levels => [ 'debug' ] }),
Log::Contextual::SimpleLogger->new({
levels => [ 'info' ],
coderef => sub { print @_ },
}),
]});
## docs below here not yet edited
log_info { 'program started' }; # no-op because info is not in levels
sub foo {
log_debug { 'entered foo' };
...
}
Not me keeping the ## docs below here not yet edited comment and the # no-op because info is not in levels note exactly as they are β because thatβs what the page says, bestie. π
π DESCRIPTION π
okay so real talk: this module is a simple logger made mostly for demonstration and initial experimentation with Log::Contextual. Thatβs the vibe. We literally recommend you use a real logger instead. π
If you want something more serious but not overly complicated, go take a look at Log::Dispatchouli. Sheβs right there. π«Ά
π οΈ METHODS π οΈ
Letβs go method by method, bestie. No skipping. π
π new
Arguments: Dict[ levels => ArrayRef[Str], coderef => Optional[CodeRef] ] $conf
my $l = Log::Contextual::SimpleLogger->new({
levels => [qw( info warn )],
coderef => sub { print @_ }, # the default prints to STDERR
});
This makes a brand-new SimpleLogger object with the levels you passed in enabled. Optionally, you can pass a CodeRef to modify how the logs get output or stored β cute little customization moment. β¨
Levels may contain:
tracedebuginfowarnerrorfatal
ποΈ $level
Arguments: @anything
All of the following six methods work the same. The basic pattern is:
sub $level {
my $self = shift;
print STDERR "[$level] " . join qq{\n}, @_;
if $self->is_$level;
}
trace
The call looks like:
$l->trace( 'entered method foo with args ' join q{,}, @args );
debug
The call looks like:
$l->debug( 'entered method foo' );
info
The call looks like:
$l->info( 'started process foo' );
warn
The call looks like:
$l->warn( 'possible misconfiguration at line 10' );
error
The call looks like:
$l->error( 'non-numeric user input!' );
fatal
The call looks like:
$l->fatal( '1 is never equal to 0!' );
Note:fataldoes not calldiefor you β see"EXCEPTIONS AND ERROR HANDLING"inLog::Contextualβ yes, thatβs the note, donβt shoot the messenger. π
β
is_$level
These six little check-in functions just return true if their respective level is enabled. Simple. Clean. Vibe check passed. β
is_trace
say 'tracing' if $l->is_trace;
is_debug
say 'debuging' if $l->is_debug;
is_info
say q{info'ing} if $l->is_info;
is_warn
say 'warning' if $l->is_warn;
is_error
say 'erroring' if $l->is_error;
is_fatal
say q{fatal'ing} if $l->is_fatal;
π BUGS π
Found a bug? Want a feature? Please report it on the bugtracker website: https://github.com/haarg/Log-Contextual/issues β sheβs waiting. ππ«Ά
When you submit a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. Thatβs the whole ask. No vibes-only reports, bestie. π
π AUTHOR π
Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com> β the author, the icon, the legend. π
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2024 by Arthur Axel "fREW" Schmidt. π«Ά
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Periodt. π
okay bestie, thatβs the whole page. The footer says perl v5.42.0, dated 2024-06-23, and the manual name is Log::Co...eLogger(3) β so now you know the source/version and date too. Go log something, and remember: output to more than one logger is a lifestyle. π
β¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Log-Contextual 0.009001-bp160.1.11 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms