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 mode
  • callback β€” Default: <required> (yeah she's mandatory, more on her below)
  • charset β€” Defined in: Log::Report::Dispatcher β€” Default: undef
  • format_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 your callback is called with five parameters: this dispatcher object, the options, a reason and a message. the options are the first parameter of Log::Report::report() (read over there, bestie πŸ‘€). the reason is a capitized string like "ERROR". then, the message (is a Log::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 a CODE ref if you're feeling spicy. πŸ”₯
  • locale => LOCALE β€” the locale.
  • mode => 'NORMAL'|'VERBOSE'|'ASSERT'|'DEBUG'|0..3 β€” the mode, and yes it also takes numbers 0..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 by new(). 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