1Log::Report::DispatcherU:s:eCralClobnatcrki(b3u)ted PerlLoDgo:c:uRmeepnotratt:i:oDnispatcher::Callback(3)
2
3
4
6 Log::Report::Dispatcher::Callback - call a code-ref for each log-line
7
9 Log::Report::Dispatcher::Callback
10 is a Log::Report::Dispatcher
11
13 sub cb($$$)
14 { my ($disp, $options, $reason, $message) = @_;
15 ...
16 }
17
18 dispatcher Log::Report::Dispatcher::Callback => 'cb'
19 , callback => \&cb;
20
21 dispatcher CALLBACK => 'cb' # same
22 , callback => \&cb;
23
25 This basic file logger accepts a callback, which is called for each
26 message which is to be logged. When you need complex things, you may
27 best make your own extension to Log::Report::Dispatcher, but for simple
28 things this will do.
29
30 Extends "DESCRIPTION" in Log::Report::Dispatcher.
31
32 . Example
33
34 sub send_mail($$$)
35 { my ($disp, $options, $reason, $message) = @_;
36 my $msg = Mail::Send->new(Subject => $reason
37 , To => 'admin@localhost');
38 my $fh = $msg->open('sendmail');
39 print $fh $disp->translate($reason, $message);
40 close $fh;
41 }
42
43 dispatcher CALLBACK => 'mail', callback => \&send_mail;
44
46 Extends "METHODS" in Log::Report::Dispatcher.
47
48 Constructors
49 Extends "Constructors" in Log::Report::Dispatcher.
50
51 $obj->close()
52 Inherited, see "Constructors" in Log::Report::Dispatcher
53
54 Log::Report::Dispatcher::Callback->new($type, $name, %options)
55 -Option --Defined in --Default
56 accept Log::Report::Dispatcher depend on mode
57 callback <required>
58 charset Log::Report::Dispatcher <undef>
59 format_reason Log::Report::Dispatcher 'LOWERCASE'
60 locale Log::Report::Dispatcher <system locale>
61 mode Log::Report::Dispatcher 'NORMAL'
62
63 accept => REASONS
64 callback => CODE
65 Your "callback" is called with five parameters: this dispatcher
66 object, the options, a reason and a message. The "options" are
67 the first parameter of Log::Report::report() (read over there).
68 The "reason" is a capitized string like "ERROR". Then, the
69 "message" (is a Log::Report::Message). Finally the text-domain
70 of the message.
71
72 charset => CHARSET
73 format_reason => 'UPPERCASE'|'LOWERCASE'|'UCFIRST'|'IGNORE'|CODE
74 locale => LOCALE
75 mode => 'NORMAL'|'VERBOSE'|'ASSERT'|'DEBUG'|0..3
76
77 Accessors
78 Extends "Accessors" in Log::Report::Dispatcher.
79
80 $obj->callback()
81 Returns the code reference which will handle each logged message.
82
83 $obj->isDisabled()
84 Inherited, see "Accessors" in Log::Report::Dispatcher
85
86 $obj->mode()
87 Inherited, see "Accessors" in Log::Report::Dispatcher
88
89 $obj->name()
90 Inherited, see "Accessors" in Log::Report::Dispatcher
91
92 $obj->needs( [$reason] )
93 Inherited, see "Accessors" in Log::Report::Dispatcher
94
95 $obj->type()
96 Inherited, see "Accessors" in Log::Report::Dispatcher
97
98 Logging
99 Extends "Logging" in Log::Report::Dispatcher.
100
101 $obj->addSkipStack(@CODE)
102 Log::Report::Dispatcher::Callback->addSkipStack(@CODE)
103 Inherited, see "Logging" in Log::Report::Dispatcher
104
105 $obj->collectLocation()
106 Log::Report::Dispatcher::Callback->collectLocation()
107 Inherited, see "Logging" in Log::Report::Dispatcher
108
109 $obj->collectStack( [$maxdepth] )
110 Log::Report::Dispatcher::Callback->collectStack( [$maxdepth] )
111 Inherited, see "Logging" in Log::Report::Dispatcher
112
113 $obj->log(HASH-$of-%options, $reason, $message, $domain)
114 Inherited, see "Logging" in Log::Report::Dispatcher
115
116 $obj->skipStack()
117 Inherited, see "Logging" in Log::Report::Dispatcher
118
119 $obj->stackTraceLine(%options)
120 Log::Report::Dispatcher::Callback->stackTraceLine(%options)
121 Inherited, see "Logging" in Log::Report::Dispatcher
122
123 $obj->translate(HASH-$of-%options, $reason, $message)
124 Inherited, see "Logging" in Log::Report::Dispatcher
125
127 Extends "DETAILS" in Log::Report::Dispatcher.
128
130 This module is part of Log-Report distribution version 1.32, built on
131 January 26, 2021. Website: http://perl.overmeer.net/CPAN/
132
134 Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other
135 contributors see ChangeLog.
136
137 This program is free software; you can redistribute it and/or modify it
138 under the same terms as Perl itself. See http://dev.perl.org/licenses/
139
140
141
142perl v5.32.1 2021-01-2L6og::Report::Dispatcher::Callback(3)