1Net::Daemon::Log(3) User Contributed Perl Documentation Net::Daemon::Log(3)
2
3
4
6 Net::Daemon::Log - Utility functions for logging
7
9 # Choose logging method: syslog or Win32::EventLog
10 $self->{'facility'} = 'mail'; # Default: Daemon
11 $self->{'logfile'} = undef; # Default
12
13 # Choose logging method: stderr
14 $self->{'logfile'} = 1;
15
16 # Choose logging method: IO handle
17 my $file = IO::File->new("my.log", "a");
18 $self->{'logfile'} = $file;
19
20
21 # Debugging messages (equivalent):
22 $self->Log('debug', "This is a debugging message");
23 $self->Debug("This is a debugging message");
24
25 # Error messages (equivalent):
26 $self->Log('err', "This is an error message");
27 $self->Error("This is an error message");
28
29 # Fatal error messages (implies 'die')
30 $self->Fatal("This is a fatal error message");
31
33 THIS IS ALPHA SOFTWARE. It is *only* 'Alpha' because the interface
34 (API) is not finalised. The Alpha status does not reflect code quality
35 or stability.
36
38 Net::Daemon::Log is a utility class for portable logging messages. By
39 default it uses syslog (Unix) or Win32::EventLog (Windows), but logging
40 messages can also be redirected to stderr or a log file.
41
42 Generic Logging
43 $self->Log($level, $msg, @args);
44
45 This is the generic interface. The logging level is in syslog style,
46 thus one of the words 'debug', 'info', 'notice', 'err' or 'crit'.
47 You'll rarely need info and notice and I can hardly imagine a reason
48 for crit (critical). In 95% of all cases debug and err will be
49 sufficient.
50
51 The logging string $msg is a format string similar to printf.
52
53 Utility methods
54 $self->Debug($msg, @args);
55 $self->Error($msg, @args);
56 $self->Fatal($msg, @args);
57
58 These are replacements for logging with levels debug and err. The
59 difference between the latter two is that Fatal includes throwing a
60 Perl exception.
61
62 Chossing a logging target
63 By default logging will happen to syslog (Unix) or EventLog (Windows).
64 However you may choose logging to stderr by setting
65
66 $self->{'logfile'} = 1;
67
68 This is required if neither of syslog and EventLog is available. An
69 alternative option is setting
70
71 $self->{'logfile'} = $handle;
72
73 where $handle is any object supporting a print method, for example an
74 IO::Handle object. Usually the logging target is choosen as soon as you
75 call $self->Log() the first time. However, you may force choosing the
76 target by doing a
77
78 $self->OpenLog();
79
80 before calling Log the first time.
81
83 The Multithreading capabitities of this class are depending heavily on
84 the underlying classes Sys::Syslog, Win32::EventLog or IO::Handle. If
85 they are thread safe, you can well assume that this package is too.
86 (The exception being that you should better call $self->OpenLog()
87 before threading.)
88
90 Net::Daemon is Copyright (C) 1998, Jochen Wiedmann
91 Am Eisteich 9
92 72555 Metzingen
93 Germany
94
95 Phone: +49 7123 14887
96 Email: joe@ispsoft.de
97
98 All rights reserved.
99
100 You may distribute this package under the terms of either the GNU
101 General Public License or the Artistic License, as specified in the
102 Perl README file.
103
105 Net::Daemon(3), Sys::Syslog(3), Win32::EventLog(3), IO::Handle(3)
106
107
108
109perl v5.16.3 2011-03-01 Net::Daemon::Log(3)