Log::Co...leLogger(3)
πΈ NAME πΈ
This page is Log::Co...leLogger(3) from User Contributed Perl Documentation, and the module it's about is Log::Contextual::SimpleLogger β literally a super simple logger made for playing with Log::Contextual. π
π VERSION π
Okay so the version is 0.009001. Slay.
β¨ SYNOPSIS β¨
Bestie, here's the vibe:
use Log::Contextual::SimpleLogger;
use Log::Contextual qw( :log ),
-logger => Log::Contextual::SimpleLogger->new({ levels => [qw( debug )]});
log_info { 'program started' }; # no-op because info is not in levels
sub foo {
log_debug { 'entered foo' };
...
}
π¦ DESCRIPTION π¦
Okay so this module is a simple logger, mostly for demonstration and first-time experimentation with Log::Contextual. Real talk: use a real logger instead. If you want something more serious but not overly complicated, take a look at Log::Dispatchouli β iykyk. β¨
π METHODS π
π§ new π§
Arguments: the signature is literally this:
Dict[
levels => Optional[ArrayRef[Str]],
levels_upto => Level,
coderef => Optional[CodeRef], ] $conf
You can call it like this:
my $l = Log::Contextual::SimpleLogger->new({
levels => [qw( info warn )],
coderef => sub { print @_ }, # the default prints to STDERR
});
or:
my $l = Log::Contextual::SimpleLogger->new({
levels_upto => 'debug',
coderef => sub { print @_ }, # the default prints to STDERR
});
This creates a new SimpleLogger object with the levels you passed enabled. If you want, you can also pass a CodeRef to change how the logs are output/stored. levels_upto turns on all the levels up to and including the level you pass in.
The levels can be:
trace
debug
info
warn
error
fatal
π $level π
Arguments: @anything.
All of the following six methods work the same way. The basic pattern is:
sub $level {
my $self = shift;
print STDERR "[$level] " . join qq{\n}, @_;
if $self->is_$level;
}
trace
$l->trace( 'entered method foo with args ' join q{,}, @args );
debug
$l->debug( 'entered method foo' );
info
$l->info( 'started process foo' );
warn
$l->warn( 'possible misconfiguration at line 10' );
error
$l->error( 'non-numeric user input!' );
fatal
$l->fatal( '1 is never equal to 0!' );
Heads up:fataldoes not calldiefor you β see "EXCEPTIONS AND ERROR HANDLING" inLog::Contextual.
π is_$level π
All of the following six functions just return true if their respective level is enabled. That's it, that's the whole vibe.
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 π
Please report any bugs or feature requests on the bugtracker website <https://github.com/haarg/Log-Contextual/issues>.
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. No cap, that's the whole ask. π«Ά
π AUTHOR π
Shoutout to Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>.
π 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.
π cute sign-off: this page is fromperl v5.42.0, dated2024-06-23, and the manual name isLog::Co...leLogger(3). periodt. π
π¦ 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