The Sys::Syslog module acts like your C library's syslog(3) function, sending messages to your system log daemon, syslogd(8). It is especially useful in daemons and other programs lacking a terminal to receive diagnostic output, or for security-minded programs that want to produce a more lasting record of their actions (or someone else's actions). Supported functions are:use Sys::Syslog; # Misses setlogsock. use Sys::Syslog qw(:DEFAULT setlogsock); # Also gets setlogsock. openlog($program, 'cons,pid', 'user'); syslog('info', 'this is another test'); syslog('mail|warning', 'this is a better test: %d', time()); closelog(); syslog('debug', 'this is the last test'); setlogsock('unix'); openlog("$program $$", 'ndelay', 'user'); syslog('info', 'problem was %m'); # %m == $! in syslogese syslog('notice', 'fooprogram: this is really done'); setlogsock("unix"); # "inet" or "unix" openlog("myprogname", $logopt, $facility); syslog($priority, $format, @args); $oldmask = setlogmask($mask_priority); closelog();
Establishes a connection with your friendly syslog daemon. IDENT is the string to log messages under (like $0, your program name). OPTLIST is a string with comma-separated options such as "cons", "pid", and "ndelay". FACILITY is something like "auth", "daemon", "kern", "lpr", "mail", "news" or "user" for system programs, and one of "local0" .. "local7" for local ones. Further messages are logged using the given facility and identifying string.
Sends a message to the daemon using the given PRIORITY. The FORMAT is just like printf--filling in percent escapes using the following ARGS--except that following the conventions of the standard syslog(3) library function, the special escape "%m" interpolates errno (Perl's $! variable) at that point.
TYPE must be either "inet" or "unix". Some systems' daemons do not by default pay attention to incoming Internet-domain syslog messages, so you might set this to "unix" instead, since it's not the default.
Severs the connection with the daemon.
For this module to work prior to the 5.6.0 release of Perl, your sysadmin had to run h2ph(1) on your sys/syslog.h include file to create a sys/syslog.ph library file. However, this wasn't done by default at Perl installation time. Later releases now use an XS interface, so the sys/syslog.ph preparation is no longer needed.
Copyright © 2001 O'Reilly & Associates. All rights reserved.
HIVE: All information for read only. Please respect copyright! |