Log::Report::Dispatcher::Callback3pm
Call a code-ref for each log-line
Usage
sub cb($$$){ my ($disp, $options, $reason, $message) = @_;...}dispatcher Log::Report::Dispatcher::Callback => 'cb',callback => \&cb;dispatcher CALLBACK => 'cb', # samecallback => \&cb;
Inheritance
Log::Report::Dispatcher::Callbackis a Log::Report::Dispatcher
Overview
This basic file logger accepts a callback, which is called for each message which is to be logged. When you need complex things, you may best make your own extension to Log::Report::Dispatcher, but for simple things this will do.
Extends "DESCRIPTION" in Log::Report::Dispatcher.
» Example
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;
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
-Option --Defined in --Defaultaccept Log::Report::Dispatcher depend on modecallback <required>charset Log::Report::Dispatcher undefformat_reason Log::Report::Dispatcher 'LOWERCASE'locale Log::Report::Dispatcher <system locale>mode Log::Report::Dispatcher 'NORMAL'- accept => $reasons|\@reasons
- callback => CODE
-
Your
"callback"is called with five parameters: this dispatcher object, the options, a reason and a message. The"options"are the first parameter ofLog::Report::report()(read over there). The"reason"is a capitized string like"ERROR". Then, the"message"(is a Log::Report::Message). Finally the text-domain of the message.
- charset => CHARSET
- format_reason => 'UPPERCASE'|'LOWERCASE'|'UCFIRST'|'IGNORE'|CODE
- locale => LOCALE
- mode => 'NORMAL'|'VERBOSE'|'ASSERT'|'DEBUG'|0..3
Attributes
Extends "Attributes" in Log::Report::Dispatcher.
$obj->
|
Returns the code reference which will handle each logged message. |
|---|---|
$obj->
|
Inherited, see "Attributes" in Log::Report::Dispatcher |
$obj->
|
Inherited, see "Attributes" in Log::Report::Dispatcher |
$obj->
|
Inherited, see "Attributes" in Log::Report::Dispatcher |
$obj->
|
Inherited, see "Attributes" in Log::Report::Dispatcher |
$obj->
|
Inherited, see "Attributes" in Log::Report::Dispatcher |
Logging
Extends "Logging" in Log::Report::Dispatcher.
$any->
|
Inherited, see "Logging" in Log::Report::Dispatcher |
|---|---|
$obj->
|
Inherited, see "Logging" in Log::Report::Dispatcher |
$any->
|
Inherited, see "Logging" in Log::Report::Dispatcher |
$any->
|
Inherited, see "Logging" in Log::Report::Dispatcher |
$obj->
|
Inherited, see "Logging" in Log::Report::Dispatcher |
$obj->
|
Inherited, see "Logging" in Log::Report::Dispatcher |
$any->
|
Inherited, see "Logging" in Log::Report::Dispatcher |
$obj->
|
Inherited, see "Logging" in Log::Report::Dispatcher |
Details
Extends "DETAILS" in Log::Report::Dispatcher.
Diagnostics
- Error: dispatcher $name needs a 'callback'
-
Cast by
new()
Releases
8 releases since Debian 7 (Wheezy); the text changed 7 times.