1Log::Dispatch::Email(3)User Contributed Perl DocumentatioLnog::Dispatch::Email(3)
2
3
4

NAME

6       Log::Dispatch::Email - Base class for objects that send log messages
7       via email
8

SYNOPSIS

10         package Log::Dispatch::Email::MySender
11
12         use Log::Dispatch::Email;
13         use base qw( Log::Dispatch::Email );
14
15         sub send_email
16         {
17             my $self = shift;
18             my %p = @_;
19
20             # Send email somehow.  Message is in $p{message}
21         }
22

DESCRIPTION

24       This module should be used as a base class to implement Log::Dis‐
25       patch::* objects that send their log messages via email.  Implementing
26       a subclass simply requires the code shown in the SYNOPSIS with a real
27       implementation of the "send_email()" method.
28

METHODS

30       * new(%p)
31           This method takes a hash of parameters.  The following options are
32           valid:
33
34           * name ($)
35                   The name of the object (not the filename!).  Required.
36
37           * min_level ($)
38                   The minimum logging level this object will accept.  See the
39                   Log::Dispatch documentation on Log Levels for more informa‐
40                   tion.  Required.
41
42           * max_level ($)
43                   The maximum logging level this obejct will accept.  See the
44                   Log::Dispatch documentation on Log Levels for more informa‐
45                   tion.  This is not required.  By default the maximum is the
46                   highest possible level (which means functionally that the
47                   object has no maximum).
48
49           * subject ($)
50                   The subject of the email messages which are sent.  Defaults
51                   to "$0: log email"
52
53           * to ($ or \@)
54                   Either a string or a list reference of strings containing
55                   email addresses.  Required.
56
57           * from ($)
58                   A string containing an email address.  This is optional and
59                   may not work with all mail sending methods.
60
61           * buffered (0 or 1)
62                   This determines whether the object sends one email per mes‐
63                   sage it is given or whether it stores them up and sends
64                   them all at once.  The default is to buffer messages.
65
66           * callbacks( \& or [ \&, \&, ... ] )
67                   This parameter may be a single subroutine reference or an
68                   array reference of subroutine references.  These callbacks
69                   will be called in the order they are given and passed a
70                   hash containing the following keys:
71
72                    ( message => $log_message, level => $log_level )
73
74                   The callbacks are expected to modify the message and then
75                   return a single scalar containing that modified message.
76                   These callbacks will be called when either the "log" or
77                   "log_to" methods are called and will only be applied to a
78                   given message once.
79
80       * log_message( message => $ )
81           Sends a message to the appropriate output.  Generally this
82           shouldn't be called directly but should be called through the
83           "log()" method (in Log::Dispatch::Output).
84
85       * send_email(%p)
86           This is the method that must be subclassed.  For now the only
87           parameter in the hash is 'message'.
88
89       * flush
90           If the object is buffered, then this method will call the
91           "send_email()" method to send the contents of the buffer and then
92           clear the buffer.
93
94       * DESTROY
95           On destruction, the object will call "flush()" to send any pending
96           email.
97

AUTHOR

99       Dave Rolsky, <autarch@urth.org>
100
101
102
103perl v5.8.8                       2006-12-20           Log::Dispatch::Email(3)
Impressum