1Log::Dispatch::Output(3U)ser Contributed Perl DocumentatiLoong::Dispatch::Output(3)
2
3
4

NAME

6       Log::Dispatch::Output - Base class for all Log::Dispatch::* objects
7

VERSION

9       version 2.27
10

SYNOPSIS

12         package Log::Dispatch::MySubclass;
13
14         use Log::Dispatch::Output;
15         use base qw( Log::Dispatch::Output );
16
17         sub new {
18             my $proto = shift;
19             my $class = ref $proto || $proto;
20
21             my %p = @_;
22
23             my $self = bless {}, $class;
24
25             $self->_basic_init(%p);
26
27             # Do more if you like
28
29             return $self;
30         }
31
32         sub log_message {
33             my $self = shift;
34             my %p    = @_;
35
36             # Do something with message in $p{message}
37         }
38
39         1;
40

DESCRIPTION

42       This module is the base class from which all Log::Dispatch::* objects
43       should be derived.
44

CONSTRUCTOR

46       The constructor, "new", must be overridden in a subclass. See Output
47       Classes for a description of the common parameters accepted by this
48       constructor.
49

METHODS

51       ·   _basic_init(%p)
52
53           This should be called from a subclass's constructor.  Make sure to
54           pass the arguments in @_ to it.  It sets the object's name and
55           minimum level.  It also sets up two other attributes which are used
56           by other Log::Dispatch::Output methods, level_names and
57           level_numbers.
58
59       ·   name
60
61           Returns the object's name.
62
63       ·   min_level
64
65           Returns the object's minimum log level.
66
67       ·   max_level
68
69           Returns the object's maximum log level.
70
71       ·   accepted_levels
72
73           Returns a list of the object's accepted levels (by name) from
74           minimum to maximum.
75
76       ·   log( level => $, message => $ )
77
78           Sends a message if the level is greater than or equal to the
79           object's minimum level.  This method applies any message formatting
80           callbacks that the object may have.
81
82       ·   _should_log ($)
83
84           This method is called from the "log()" method with the log level of
85           the message to be logged as an argument.  It returns a boolean
86           value indicating whether or not the message should be logged by
87           this particular object.  The "log()" method will not process the
88           message if the return value is false.
89
90       ·   _level_as_number ($)
91
92           This method will take a log level as a string (or a number) and
93           return the number of that log level.  If not given an argument, it
94           returns the calling object's log level instead.  If it cannot
95           determine the level then it will croak.
96
97       ·   add_callback( $code )
98
99           Adds a callback (like those given during construction). It is added
100           to the end of the list of callbacks.
101
102   Subclassing
103       This class should be used as the base class for all logging objects you
104       create that you would like to work under the Log::Dispatch
105       architecture.  Subclassing is fairly trivial.  For most subclasses, if
106       you simply copy the code in the SYNOPSIS and then put some
107       functionality into the "log_message" method then you should be all set.
108       Please make sure to use the "_basic_init" method as directed.
109
110       The actual logging implementation should be done in a "log_message"
111       method that you write. Do not override "log"!.
112

AUTHOR

114       Dave Rolsky <autarch@urth.org>
115
117       This software is Copyright (c) 2010 by Dave Rolsky.
118
119       This is free software, licensed under:
120
121         The Artistic License 2.0
122
123
124
125perl v5.12.2                      2010-10-16          Log::Dispatch::Output(3)
Impressum