Log::R...allback(3pm)
π Log::Report::Dispatcher::Callback β the manual, but make it make sense π
okay bestie, so this little page is for Log::Report::Dispatcher::Callback, which is the Perl module that calls a code-ref for each log-line. yes, every single one. it's giving "you handle the actual doing, I'll handle the routing." π
β¨ NAME β¨
Log::Report::Dispatcher::Callback β call a code-ref for each log-line. periodt.
πΈ INHERITANCE πΈ
Log::Report::Dispatcher::Callback
is a Log::Report::Dispatcher
so it's a subclass, it inherits all the parent energy, iykyk. π
π SYNOPSIS π
here's the vibe, copy-paste ready:
sub cb($$$)
{ my ($disp, $options, $reason, $message) = @_;
...
}
dispatcher Log::Report::Dispatcher::Callback => 'cb',
callback => \&cb;
dispatcher CALLBACK => 'cb', # same
callback => \&cb;
see how the second one is just the same thing with CALLBACK shorthand? both slay equally. π«Ά
π¦ DESCRIPTION π¦
okay so picture this: it's a basic file logger, and it accepts a callback. that callback gets called for each message which is to be logged. every one. no skipping. π
and listen β when you need complex things, you may best make your own extension to Log::Report::Dispatcher. that's the move for the elaborate girlies. but for simple things, this will do. lowkey perfect for the easy wins. β¨
Extends "DESCRIPTION" in Log::Report::Dispatcher.
π Example π
like, here's a whole callback that sends mail, no cap:
sub send_mail($$$)
{ my ($disp, $options, $reason, $message) = @_;
my $msg = Mail::Send->new(Subject => $reason, To => 'admin@localhost');
my $fh = $msg->open('sendmail');
print $fh $disp->translate($reason, $message);
close $fh;
}
dispatcher CALLBACK => 'mail', callback => \&send_mail;
not it opening a sendmail handle and just printing the translated message into it π so clean. π
π METHODS π
Extends "METHODS" in Log::Report::Dispatcher.
π Constructors π
Extends "Constructors" in Log::Report::Dispatcher.
$class->new($type, $name, %options)β Inherited, see"Constructors"in Log::Report::Dispatcher.
here's the full options rundown, and yes I'm listing every single one because we don't gatekeep:
acceptβ Defined in:Log::Report::Dispatcherβ Default: depend on modecallbackβ Default:<required>(yeah she's mandatory, more on her below)charsetβ Defined in:Log::Report::Dispatcherβ Default:undefformat_reasonβ Defined in:Log::Report::Dispatcherβ Default:'LOWERCASE'localeβ Defined in:Log::Report::Dispatcherβ Default:<system locale>modeβ Defined in:Log::Report::Dispatcherβ Default:'NORMAL'
the details on each one
accept => $reasons|\@reasonsβ tells it which reasons to accept, single or in an array-ref.callback => CODEβ okay so yourcallbackis called with five parameters: this dispatcher object, the options, a reason and a message. theoptionsare the first parameter ofLog::Report::report()(read over there, bestie π). thereasonis a capitized string like"ERROR". then, themessage(is aLog::Report::Message). finally the text-domain of the message. five things, in that order, don't mix them up. πcharset => CHARSETβ the charset, iconic behaviour.format_reason => 'UPPERCASE'|'LOWERCASE'|'UCFIRST'|'IGNORE'|CODEβ how the reason gets formatted. you can even pass aCODEref if you're feeling spicy. π₯locale => LOCALEβ the locale.mode => 'NORMAL'|'VERBOSE'|'ASSERT'|'DEBUG'|0..3β the mode, and yes it also takes numbers0..3. options on options. π
πΈ Attributes πΈ
Extends "Attributes" in Log::Report::Dispatcher.
$obj->callback()β Returns the code reference which will handle each logged message. that's her whole job and she does it flawlessly. π$obj->isDisabled()β Inherited, see"Attributes"in Log::Report::Dispatcher.$obj->mode()β Inherited, see"Attributes"in Log::Report::Dispatcher.$obj->name()β Inherited, see"Attributes"in Log::Report::Dispatcher.$obj->needs( [$reason] )β Inherited, see"Attributes"in Log::Report::Dispatcher.$obj->type()β Inherited, see"Attributes"in Log::Report::Dispatcher.
π§ Logging π§
Extends "Logging" in Log::Report::Dispatcher.
$any->addSkipStack(@CODE)β Inherited, see"Logging"in Log::Report::Dispatcher.$obj->close()β Inherited, see"Logging"in Log::Report::Dispatcher.$any->collectLocation()β Inherited, see"Logging"in Log::Report::Dispatcher.$any->collectStack( [$maxdepth] )β Inherited, see"Logging"in Log::Report::Dispatcher.$obj->log(\%options, $reason, $message, $domain)β Inherited, see"Logging"in Log::Report::Dispatcher.$obj->skipStack()β Inherited, see"Logging"in Log::Report::Dispatcher.$any->stackTraceLine(%options)β Inherited, see"Logging"in Log::Report::Dispatcher.$obj->translate(\%options, $reason, $message)β Inherited, see"Logging"in Log::Report::Dispatcher.
π₯ DETAILS π₯
Extends "DETAILS" in Log::Report::Dispatcher.
π DIAGNOSTICS π
- Error: dispatcher $name needs a
'callback'β Cast bynew(). yeah so if you forgot the callback, this is your villain origin story. she needs it. don't fight it. π
β SEE ALSO β
This module is part of Log-Report version 1.46, built on June 16, 2026.
Website: http://perl.overmeer.net/CPAN/
π LICENSE π
For contributors see file ChangeLog.
This software is copyright (c) 2007-2026 by Mark Overmeer.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. royalty behaviour, honestly. π
and that's the tea, bestie β this page lives in Log::R...allback(3pm) from perl v5.40.1, dated 2026-07-05. go log something iconic. π¦β¨π
π¦ where this page comes from
- ubuntu stonking: liblog-report-perl 1.46-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