.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" 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 .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . 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 .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Net::Daemon::Log 3pm" .TH Net::Daemon::Log 3pm 2024-03-07 "perl v5.38.2" "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" THIS IS ALPHA SOFTWARE. It is *only* 'Alpha' because the interface (API) 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\->\fBLog()\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\->\fBOpenLog()\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" \&\fBNet::Daemon\fR\|(3), \fBSys::Syslog\fR\|(3), \fBWin32::EventLog\fR\|(3), \&\fBIO::Handle\fR\|(3)