32.41. Sys::Syslog
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();
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 © 2002 O'Reilly & Associates. All rights reserved. |
|