Seth Woolley's Man Viewer

Sys::Syslog(3) - Sys::Syslog, closelog, openlog, setlogmask, syslog - Perl interface to the UNIX syslog(3) calls - man 3 Sys::Syslog

([section] manual, -k keyword, -K [section] search, -f whatis)
man plain no title

Sys::Syslog(3)         Perl Programmers Reference Guide         Sys::Syslog(3)



NAME
       Sys::Syslog, openlog, closelog, setlogmask, syslog(2,3,5,3 Sys::Syslog) - Perl interface to
       the UNIX syslog(2,3,5,3 Sys::Syslog)(3) calls

SYNOPSIS
           use Sys::Syslog;                          # all except setlogsock, or:
           use Sys::Syslog qw(:DEFAULT setlogsock);  # default set(7,n,1 builtins), plus setlogsock

           setlogsock $sock_type;
           openlog $ident, $logopt, $facility;       # don't forget this
           syslog(2,3,5,3 Sys::Syslog) $priority, $format, @args;
           $oldmask = setlogmask $mask_priority;
           closelog;

DESCRIPTION
       Sys::Syslog is an interface to the UNIX syslog(2,3,5,3 Sys::Syslog)(3) program.  Call "sys-
       log()" with a string(3,n) priority and a list of "printf(1,3,1 builtins)()" args just like
       syslog(2,3,5,3 Sys::Syslog)(3).

       Syslog provides the functions:

       openlog $ident, $logopt, $facility
           $ident is prepended to every message.  $logopt contains zero or
           more of the words pid, ndelay, nowait.  The cons option is ignored,
           since the failover mechanism will drop down to the console(4,n) automat-
           ically if(3,n) all other media fail.  $facility specifies the part of
           the system to report about, for example LOG_USER or LOG_LOCAL0: see
           your syslog(2,3,5,3 Sys::Syslog)(3) documentation for the facilities available in(1,8) your
           system.

           You should use openlog() before calling syslog(2,3,5,3 Sys::Syslog)().

       syslog(2,3,5,3 Sys::Syslog) $priority, $format, @args
           If $priority permits, logs ($format, @args) printed as by
           "printf(1,3,1 builtins)(3V)", with the addition that %m is replaced with "$!" (the
           latest error(8,n) message).

           If you didn't use openlog() before using syslog(2,3,5,3 Sys::Syslog)(), syslog(2,3,5,3 Sys::Syslog) will try
           to guess the $ident by extracting the shortest prefix of $format
           that ends in(1,8) a ":".

       setlogmask $mask_priority
           Sets log mask $mask_priority and returns the old mask.

       setlogsock $sock_type [$stream_location] (added in(1,8) 5.004_02)
           Sets the socket(2,7,n) type to be used for the next call to "openlog()" or
           "syslog(2,3,5,3 Sys::Syslog)()" and returns TRUE on success, undef on failure.

           A value of 'unix' will connect to the UNIX domain socket(2,7,n) (in(1,8) some
           systems a character special device) returned by the "_PATH_LOG"
           macro (if(3,n) your system defines it), or /dev/log or /dev/conslog,
           whatever is writable.  A value of 'stream' will connect to the
           stream indicated by the pathname provided as the optional second
           parameter.  (For example Solaris and IRIX require 'stream' instead
           of 'unix'.)  A value of 'inet' will connect to an INET socket(2,7,n)
           (either tcp or udp, tried in(1,8) that order) returned by getservby-
           name(). 'tcp' and 'udp' can also be given as values. The value
           'console(4,n)' will send(2,n) messages directly to the console(4,n), as for the
           'cons' option in(1,8) the logopts in(1,8) openlog().

           A reference to an array can also be passed as the first parameter.
           When this calling method is used, the array should contain a list
           of sock_types which are attempted in(1,8) order.

           The default is to try tcp, udp, unix, stream, console.

           Giving an invalid value for sock_type will croak.

       closelog
           Closes the log file.

       Note that "openlog" now takes three arguments, just like openlog(3).

EXAMPLES
           openlog($program, 'cons,pid', 'user');
           syslog(2,3,5,3 Sys::Syslog)('info(1,5,n)', 'this is another test');
           syslog(2,3,5,3 Sys::Syslog)('mail(1,8)|warning', 'this is a better test: %d', time(1,2,n));
           closelog();

           syslog(2,3,5,3 Sys::Syslog)('debug', 'this is the last test');

           setlogsock('unix');
           openlog("$program $$", 'ndelay', 'user');
           syslog(2,3,5,3 Sys::Syslog)('notice', 'fooprogram: this is really done');

           setlogsock('inet');
           $! = 55;
           syslog(2,3,5,3 Sys::Syslog)('info(1,5,n)', 'problem was %m'); # %m == $! in(1,8) syslog(2,3,5,3 Sys::Syslog)(3)

SEE ALSO
       syslog(2,3,5,3 Sys::Syslog)(3)

AUTHOR
       Tom Christiansen <tchrist@perl.com> and Larry Wall <larry@wall.org>.

       UNIX domain sockets added by Sean Robinson <robinson_s@sc.maricopa.edu>
       with support from Tim Bunce <Tim.Bunce@ig.co.uk> and the perl5-porters
       mailing list.

       Dependency on syslog.ph replaced with XS code by Tom Hughes <tom@comp-
       ton.nu>.

       Code for constant()s regenerated by Nicholas Clark <nick@ccl4.org>.

       Failover to different communication modes by Nick Williams
       <Nick.Williams@morganstanley.com>.



perl v5.8.5                       2001-09-21                    Sys::Syslog(3)

References for this manual (incoming links)