.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Net::Daemon::Log 3pm" .TH Net::Daemon::Log 3pm "2016-12-21" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Net::Daemon::Log \- Utility functions for logging .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& # Choose logging method: syslog or Win32::EventLog \& $self\->{\*(Aqfacility\*(Aq} = \*(Aqmail\*(Aq; # Default: Daemon \& $self\->{\*(Aqlogfile\*(Aq} = undef; # Default \& \& # Choose logging method: stderr \& $self\->{\*(Aqlogfile\*(Aq} = 1; \& \& # Choose logging method: IO handle \& my $file = IO::File\->new("my.log", "a"); \& $self\->{\*(Aqlogfile\*(Aq} = $file; \& \& \& # Debugging messages (equivalent): \& $self\->Log(\*(Aqdebug\*(Aq, "This is a debugging message"); \& $self\->Debug("This is a debugging message"); \& \& # Error messages (equivalent): \& $self\->Log(\*(Aqerr\*(Aq, "This is an error message"); \& $self\->Error("This is an error message"); \& \& # Fatal error messages (implies \*(Aqdie\*(Aq) \& $self\->Fatal("This is a fatal error message"); .Ve .SH "WARNING" .IX Header "WARNING" \&\s-1THIS IS ALPHA SOFTWARE.\s0 It is *only* 'Alpha' because the interface (\s-1API\s0) is not finalised. The Alpha status does not reflect code quality or stability. .SH "DESCRIPTION" .IX Header "DESCRIPTION" Net::Daemon::Log is a utility class for portable logging messages. By default it uses syslog (Unix) or Win32::EventLog (Windows), but logging messages can also be redirected to stderr or a log file. .SS "Generic Logging" .IX Subsection "Generic Logging" .Vb 1 \& $self\->Log($level, $msg, @args); .Ve .PP This is the generic interface. The logging level is in syslog style, thus one of the words 'debug', 'info', 'notice', 'err' or 'crit'. You'll rarely need info and notice and I can hardly imagine a reason for crit (critical). In 95% of all cases debug and err will be sufficient. .PP The logging string \f(CW$msg\fR is a format string similar to printf. .SS "Utility methods" .IX Subsection "Utility methods" .Vb 3 \& $self\->Debug($msg, @args); \& $self\->Error($msg, @args); \& $self\->Fatal($msg, @args); .Ve .PP These are replacements for logging with levels debug and err. The difference between the latter two is that Fatal includes throwing a Perl exception. .SS "Chossing a logging target" .IX Subsection "Chossing a logging target" By default logging will happen to syslog (Unix) or EventLog (Windows). However you may choose logging to stderr by setting .PP .Vb 1 \& $self\->{\*(Aqlogfile\*(Aq} = 1; .Ve .PP This is required if neither of syslog and EventLog is available. An alternative option is setting .PP .Vb 1 \& $self\->{\*(Aqlogfile\*(Aq} = $handle; .Ve .PP where \f(CW$handle\fR is any object supporting a \fIprint\fR method, for example an IO::Handle object. Usually the logging target is choosen as soon as you call \f(CW$self\fR\->\fILog()\fR the first time. However, you may force choosing the target by doing a .PP .Vb 1 \& $self\->OpenLog(); .Ve .PP before calling Log the first time. .SH "MULTITHREADING" .IX Header "MULTITHREADING" The Multithreading capabitities of this class are depending heavily on the underlying classes Sys::Syslog, Win32::EventLog or IO::Handle. If they are thread safe, you can well assume that this package is too. (The exception being that you should better call \&\f(CW$self\fR\->\fIOpenLog()\fR before threading.) .SH "AUTHOR AND COPYRIGHT" .IX Header "AUTHOR AND COPYRIGHT" .Vb 4 \& Net::Daemon is Copyright (C) 1998, Jochen Wiedmann \& Am Eisteich 9 \& 72555 Metzingen \& Germany \& \& Phone: +49 7123 14887 \& Email: joe@ispsoft.de \& \& All rights reserved. \& \& You may distribute this package under the terms of either the GNU \& General Public License or the Artistic License, as specified in the \& Perl README file. .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fINet::Daemon\fR\|(3), \fISys::Syslog\fR\|(3), \fIWin32::EventLog\fR\|(3), \&\fIIO::Handle\fR\|(3)