Log::R...patcher(3pm)
π Log::Report::Dispatcher π
okay bestie, welcome to the manual page for Log::R...patcher(3pm) β yeah the header truncates it, it's from the User Contributed Perl Documentation, and it's the whole manage message dispatching, display or logging situation. sit down, grab a strawberry π, we're doing this.
β¨ NAME β¨
Log::Report::Dispatcher β manage message dispatching, display or logging
πΈ INHERITANCE πΈ
Log::Report::Dispatcher is extended by
Log::Report::Dispatcher::CallbackLog::Report::Dispatcher::FileLog::Report::Dispatcher::Log4perlLog::Report::Dispatcher::LogDispatchLog::Report::Dispatcher::PerlLog::Report::Dispatcher::SyslogLog::Report::Dispatcher::Try
it's giving mother class with seven iconic daughters π
π¦ SYNOPSIS π¦
use Log::Report;
# The following will be created for you automatically
dispatcher 'PERL', 'default', accept => 'NOTICE-';
dispatcher close => 'default'; # after deamonize
dispatcher 'FILE', 'log',
mode => 'DEBUG', to => '/var/log/mydir/myfile';
# Full package name is used, same as 'FILE'
dispatcher Log::Report::Dispatch::File => 'stderr',
to => \*STDERR, accept => 'NOTICE-';
no cap, that's the whole vibe right there β
π DESCRIPTION π
so in Log::Report, dispatchers are the ones handling (exception) messages that got created somewhere else. those messages were produced (thrown) by Log::Report::error() and its little friend group.
this base-class handles the creation of dispatchers, plus the common filtering rules. if you want the tea, the "DETAILS" section is down below. π«
π METHODS π
π Constructors π
$class->new($type, $name, %options)β Create a dispatcher. The$typeof back-end to start is required, and listed in the"DESCRIPTION"part of this manual-page. For various external back-ends, special wrappers are created.
the $name has to uniquely identify this dispatcher. real talk: when a second dispatcher gets created (via Log::Report::dispatcher()) with the name of an existing dispatcher, the existing one will get replaced. so like, choose your names.
all the %options that this base constructor doesn't consume get passed to the wrapped back-end. some of them will check whether all %options are understood, others just ignore unknown %options π
the defaults, laid out for you:
-Option --Default
accept depend on mode
charset undef
format_reason 'LOWERCASE'
locale <system locale>
mode 'NORMAL'
and now one by one:
accept=> $reasons|@reasons β default: depend on mode. peepLog::Report::Util::expand_reasons()for possible values. if the initial mode for this dispatcher doesn't need verbose or debug info, then those levels will not be accepted.
when the mode equals "NORMAL" (the default) then "accept"'s default is "NOTICE- ". in case of "VERBOSE" it'll be "INFO- ", "ASSERT" results in "ASSERT- ", and "DEBUG" in "ALL". β¨
charset=> CHARSET β default:undef. convert the messages into the specified character-set (codeset). by default, no conversion will take place, because the right choice cannot be determined automatically. it's giving we're not gonna guess for you πformat_reason=>'UPPERCASE'|'LOWERCASE'|'UCFIRST'|'IGNORE'|CODE β default:'LOWERCASE'. how to show the reason text that gets printed before the message. when aCODEis specified, it will be called with a translated text and the returned text is used. obsessed with the flexibility fr fr.locale=> LOCALE β default:<system locale>. overrules the global locale setting. can itself be overruled byLog::Report::report(locale). yes it's a whole hierarchy, it's giving nested situationships πmode=>'NORMAL'|'VERBOSE'|'ASSERT'|'DEBUG'|0..3β default:'NORMAL'. possible values are"NORMAL"(or0or"undef"), which will not show"INFO"or debug messages,"VERBOSE"(1; shows"INFO"not debug),"ASSERT"(2; only ignores"TRACE"messages), or"DEBUG"(3) which shows everything. see section"Run modes"inLog::Report.
you are advised to use the symbolic mode names when the mode is changed within your program: the numerical values are available for smooth Getopt::Long integration.
π Attributes π
$obj->isDisabled()β [no description given in the original, bestie, so we're just vibing with the name π§]$obj->mode()β Returns the mode in use for the dispatcher as number. seenew(mode)and"Run modes"inLog::Report.$obj->name()β Returns the unique name of this dispatcher. iconic, unique, the name π$obj->needs( [$reason] )β Returns the list with all REASONS which are needed to fulfill this dispatcher's needs. when disabled, the list is empty, but not forgotten (she remembers π).
[0.999] when only one $reason is specified, it is returned if in the list.
$obj->type()β The dispatcher type, which is usually the same as the class of this object, but not in case of wrappers like forLog::Dispatch.
π Logging π
$any->addSkipStack(@CODE)β[1.13]Add one or more"CODE"blocks of caller lines which should not be collected for stack-traces or location display. a"CODE"gets called with an ARRAY of caller information, and returns"true"when that line should get skipped.
Warning: this logic is applied globally: on all dispatchers. yep, all of them, no takebacks π
Β» example:
by default, all lines in the Log::Report packages are skipped from display, with a simple "CODE" as this:
sub in_lr { $_[0][0] =~ m/^Log\:\:Report(?:\:\:|$)/ }
Log::Report::Dispatcher->addSkipStack(\&in_lr);
the only parameter to in_lr is the return of caller(). the first element of that ARRAY is the package name of a stack line. that's the whole trick bestie β¨
$obj->close()β Terminate this dispatcher activities. the dispatcher gets disabled, to avoid the case it accidentally gets used (she's in her do not perceive me era π«₯). Returns"undef"("false") if the dispatcher was already closed.$any->collectLocation()β Collect the information to be displayed as line where the error occurred.$any->collectStack( [$maxdepth] )β Returns an ARRAY of ARRAYs with text, filename, line-number.$obj->log(\%options, $reason, $message, $domain)β This method is called byLog::Report::report()and should not be called directly. internally, it will calltranslate(), which does most of the work. it's giving backstage crew, don't touch π$obj->skipStack()β[1.13]Returns the number of nestings in the stack which should be skipped to get outside theLog::Report(and related) modules. the end-user does not want to see those internals in stack-traces. periodt.$any->stackTraceLine(%options)
the defaults for that one:
-Option --Default
abstract 1
call <required>
filename <required>
linenr <required>
max_line undef
max_params 8
package <required>
params <required>
and the breakdown, one by one:
abstract=> INTEGER β default:1. the higher the abstraction value, the less details are given about the caller. the minimum abstraction is specified, and then increased internally to make the line fit within the"max_line"margin. it's giving fade to less detail π«οΈcall=> STRING β default:<required>filename=> STRING β default:<required>linenr=> INTEGER β default:<required>max_line=> INTEGER β default:undefmax_params=> INTEGER β default:8package=> CLASS β default:<required>params=> ARRAY β default:<required>
$obj->translate(\%options, $reason, $message)β See"Processing the message", which describes the actions taken by this method. a string is returned, which ends on a new-line, and may be multi-line (in case a stack trace is produced). multi-line? she's doing the most and we love her for it π
okay that's the first half of the tea β part 2 is coming, don't go anywhere bestie π«Ά
π DETAILS π
π Available back-ends
okay so when a dispatcher gets created (via new() or Log::Report::dispatcher()), you gotta tell it the TYPE. That TYPE can either be a whole class name that extends a Log::Report::Dispatcher, or a pre-defined abbreviation of a class name. easy π
Implemented are:
Log::Report::Dispatcher::Perl(abbreviation'PERL') β uses Perl's very ownprint(),warn()anddie()to ventilate your reports. this one is the default dispatcher, bestie, it's the main character π«ΆLog::Report::Dispatcher::File(abbreviation'FILE') β logs the message into a file. the file can either be opened by the class itself, or already open before the dispatcher is created. your choice β¨Log::Report::Dispatcher::Syslog(abbreviation'SYSLOG') β sends messages straight into the system's syslog infrastructure, usingSys::Syslog. it's giving very sysadmin-core π₯οΈLog::Report::Dispatcher::Callback(abbreviation'CALLBACK') β calls anyCODEreference the moment each selected message arrives. so like, if u need to send an important message as email or SMSβ¦ this is the one π§"Log::Dispatch::*"β literally all of theLog::Dispatch::Outputextensions can be used directly.Log::Report::Dispatcher::LogDispatchwill wrap around that back-end for u π"Log::Log4perl"β use theLog::Log4perlmain object to write to dispatchers. heads up tho, this infrastructure uses a configuration file πLog::Report::Dispatcher::Try(abbreviation'TRY') β used by the functionLog::Report::try(). it collects the exceptions and can produce them on request. so iconic of it π
π¦ Processing the message
β¨ Addition information
The modules which use "Log::Report" will only specify the base of the message string. The base dispatcher and the back-ends will extend this message with additional information:
- the reason
- the filename/line-number where the problem appeared
- the filename/line-number where it problem was reported
- the error text in
$! - a stack-trace
- a trailing new-line
When the message is a translatable object (Log::Report::Message, for instance created with Log::Report::__()), then the added components will get translated as well π Otherwise, all will be in English. no cap.
Exactly what will be added depends on the actual mode of the dispatcher β change it with mode(), initiate it with new(mode).
mode mode mode mode
REASON SOURCE TE! NORM VERB ASSE DEBUG
trace program ... S
assert program ... SL SL
info program T.. S S S
notice program T.. S S S S
mistake user T.. S S S SL
warning program T.. S S SL SL
error user TE. S S SL SC
fault system TE! S S SL SC
alert system T.! SL SL SC SC
failure system TE! SL SL SC SC
panic program .E. SC SC SC SC
T - usually translated
E - exception (execution interrupted)
! - will include $! text at display
L - include filename and linenumber
S - show/print when accepted
C - stack trace (like Carp::confess())
π Filters
With a filter, you can block or modify specific messages before translation. maybe u wanna change the REASON of a report, or its content? go off π
β οΈ bestie listen: it is not possible to avoid the exit which is related to the original message, because a module's flow depends on it to happen. so don't even try, fr fr.
When there are filters defined, they will be called in order of definition. For each of the dispatchers which are called for a certain REASON (which "accept" that REASON), it is checked whether its name is listed for the filter (when no names where specified, then the filter is applied to all dispatchers).
When selected, the filter's CODE reference is called with four arguments: the dispatcher object (a Log::Report::Dispatcher), the HASH-of-OPTIONS passed as optional first argument to Log::Report::report(), the REASON, and the MESSAGE. Returned is the new REASON and MESSAGE. When the returned REASON is "undef", then the message will be ignored for that dispatcher.
π¨ Be warned about processing the MESSAGE: it is aLog::Report::Messageobject which may have a"prepend"string and"append"string or object. When the call toLog::Report::report()contained multiple comma-separated components, these will already have been joined together using concatenation (seeLog::Report::Message::concat().
Β» Example: a filter on syslog
dispatcher filter => \&myfilter, 'syslog';
# ignore all translatable and non-translatable messages containing
# the word "skip"
sub myfilter($$$$)
{ my ($disp, $opts, $reason, $message) = @_;
return () if $message->untranslated =~ m/\bskip\b/;
($reason, $message);
}
Β» Example: take all mistakes and warnings serious
dispatch filter => \&take_warns_seriously;
sub take_warns_seriously($$$$)
{ my ($disp, $opts, $reason, $message) = @_;
$reason eq 'MISTAKE' ? (ERROR => $message)
: $reason eq 'WARNING' ? (FAULT => $message)
: ($reason => $message);
}
π DIAGNOSTICS π
- Error: Perl does not support charset $cs β Cast by
new()π - Alert: cannot use class $backend:\n$@: $! β Cast by
new()π - Error: illegal format_reason '$format' for dispatcher β Cast by
new()π
π 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.
and that's a wrap, bestie!! π«Ά this little beauty shipped as perl v5.40.1, with the page dated 2026-07-05 β go forth and dispatch responsibly, ily ππΈβ¨
π¦ 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