Net::Daemon::Log - Utility functions for logging
# Choose logging method: syslog or Win32::EventLog $self->{'facility'} = 'mail'; # Default: Daemon $self->{'logfile'} = undef; # Default
# Choose logging method: stderr $self->{'logfile'} = 1;
# Choose logging method: IO handle my $file = IO::File->new("my.log", "a"); $self->{'logfile'} = $file;
# Debugging messages (equivalent): $self->Log('debug', "This is a debugging message"); $self->Debug("This is a debugging message");
# Error messages (equivalent): $self->Log('err', "This is an error message"); $self->Error("This is an error message");
# Fatal error messages (implies 'die') $self->Fatal("This is a fatal error message");
$self->Log($level, $msg, @args);
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.
The logging string $msg is a format string similar to printf.
$self->Debug($msg, @args); $self->Error($msg, @args); $self->Fatal($msg, @args);
These are replacements for logging with levels debug and err. The difference between the latter two is that Fatal includes throwing a Perl exception.
$self->{'logfile'} = 1;
This is required if neither of syslog and EventLog is available. An alternative option is setting
$self->{'logfile'} = $handle;
where $handle is any object supporting a print method, for example an IO::Handle object. Usually the logging target is choosen as soon as you call $self->Log() the first time. However, you may force choosing the target by doing a
$self->OpenLog();
before calling Log the first time.
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.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |