.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
.\" ========================================================================
.de Sh \" Subsection heading
.de Sp \" Vertical space (when we can't use .PP)
.de Vb \" Begin verbatim text
.de Ve \" End verbatim text
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
. tm Index:\\$1\t\\n%\t"\\$2"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. \" simple accents for nroff and troff
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
.\" ========================================================================
.IX Title "Sys::Syslog 3"
.TH Sys::Syslog 3 "2001-09-21" "perl v5.8.8" "Perl Programmers Reference Guide"
Sys::Syslog \- Perl interface to the UNIX syslog(3) calls
\& use Sys::Syslog; # all except setlogsock(), or:
\& use Sys::Syslog qw(:DEFAULT setlogsock); # default set, plus setlogsock()
\& use Sys::Syslog qw(:standard :macros); # standard functions, plus macros
\& setlogsock $sock_type;
\& openlog $ident, $logopt, $facility; # don't forget this
\& syslog $priority, $format, @args;
\& $oldmask = setlogmask $mask_priority;
\&\f(CW\*(C`Sys::Syslog\*(C'\fR is an interface to the \s-1UNIX\s0 \f(CWsyslog(3)\fR program.
Call \f(CW\*(C`syslog()\*(C'\fR with a string priority and a list of \f(CW\*(C`printf()\*(C'\fR args
just like \f(CWsyslog(3)\fR.
\&\f(CW\*(C`Sys::Syslog\*(C'\fR exports the following \f(CW\*(C`Exporter\*(C'\fR tags:
\&\f(CW\*(C`:standard\*(C'\fR exports the standard \f(CWsyslog(3)\fR functions:
\& openlog closelog setlogmask syslog
\&\f(CW\*(C`:extended\*(C'\fR exports the Perl specific functions for \f(CWsyslog(3)\fR:
\&\f(CW\*(C`:macros\*(C'\fR exports the symbols corresponding to most of your \f(CWsyslog(3)\fR
macros. See \*(L"\s-1CONSTANTS\s0\*(R" for the supported constants and their meaning.
By default, \f(CW\*(C`Sys::Syslog\*(C'\fR exports the symbols from the \f(CW\*(C`:standard\*(C'\fR tag.
.ie n .IP "\fBopenlog($ident, \fB$logopt\fB, \f(BI$facility\fB)\fR" 4
.el .IP "\fBopenlog($ident, \f(CB$logopt\fB, \f(CB$facility\fB)\fR" 4
.IX Item "openlog($ident, $logopt, $facility)"
\&\f(CW$ident\fR is prepended to every message. \f(CW$logopt\fR contains zero or
more of the words \f(CW\*(C`pid\*(C'\fR, \f(CW\*(C`ndelay\*(C'\fR, \f(CW\*(C`nowait\*(C'\fR. The \f(CW\*(C`cons\*(C'\fR option is
ignored, since the failover mechanism will drop down to the console
automatically if all other media fail. \f(CW$facility\fR specifies the
part of the system to report about, for example \f(CW\*(C`LOG_USER\*(C'\fR or \f(CW\*(C`LOG_LOCAL0\*(C'\fR:
see your \f(CWsyslog(3)\fR documentation for the facilities available in
your system. Facility can be given as a string or a numeric macro.
This function will croak if it can't connect to the syslog daemon.
Note that \f(CW\*(C`openlog()\*(C'\fR now takes three arguments, just like \f(CWopenlog(3)\fR.
\&\fBYou should use \f(BIopenlog()\fB before calling \f(BIsyslog()\fB.\fR
\&\f(CW\*(C`ndelay\*(C'\fR \- Open the connection immediately (normally, the connection is
opened when the first message is logged).
\&\f(CW\*(C`nowait\*(C'\fR \- Don't wait for child processes that may have been created
while logging the message. (The \s-1GNU\s0 C library does not create a child
process, so this option has no effect on Linux.)
\&\f(CW\*(C`pid\*(C'\fR \- Include \s-1PID\s0 with each message.
Open the syslog with options \f(CW\*(C`ndelay\*(C'\fR and \f(CW\*(C`pid\*(C'\fR, and with facility \f(CW\*(C`LOCAL0\*(C'\fR:
\& openlog($name, "ndelay,pid", "local0");
Same thing, but this time using the macro corresponding to \f(CW\*(C`LOCAL0\*(C'\fR:
\& openlog($name, "ndelay,pid", LOG_LOCAL0);
.ie n .IP "\fBsyslog($priority, \fB$message\fB)\fR" 4
.el .IP "\fBsyslog($priority, \f(CB$message\fB)\fR" 4
.IX Item "syslog($priority, $message)"
.ie n .IP "\fBsyslog($priority, \fB$format\fB, \f(BI@args\fB)\fR" 4
.el .IP "\fBsyslog($priority, \f(CB$format\fB, \f(CB@args\fB)\fR" 4
.IX Item "syslog($priority, $format, @args)"
If \f(CW$priority\fR permits, logs \f(CW$message\fR or \f(CW\*(C`sprintf($format, @args)\*(C'\fR
with the addition that \f(CW%m\fR in \f(CW$message\fR or \f(CW$format\fR is replaced with
\&\f(CW"$!"\fR (the latest error message).
\&\f(CW$priority\fR can specify a level, or a level and a facility. Levels and
facilities can be given as strings or as macros.
If you didn't use \f(CW\*(C`openlog()\*(C'\fR before using \f(CW\*(C`syslog()\*(C'\fR, \f(CW\*(C`syslog()\*(C'\fR will
try to guess the \f(CW$ident\fR by extracting the shortest prefix of
\&\f(CW$format\fR that ends in a \f(CW":"\fR.
\& syslog("info", $message); # informational level
\& syslog(LOG_INFO, $message); # informational level
\& syslog("info|local0", $message); # information level, Local0 facility
\& syslog(LOG_INFO|LOG_LOCAL0, $message); # information level, Local0 facility
\&\f(CW\*(C`Sys::Syslog\*(C'\fR version v0.07 and older passed the \f(CW$message\fR as the
formatting string to \f(CW\*(C`sprintf()\*(C'\fR even when no formatting arguments
were provided. If the code calling \f(CW\*(C`syslog()\*(C'\fR might execute with
older versions of this module, make sure to call the function as
\&\f(CW\*(C`syslog($priority, "%s", $message)\*(C'\fR instead of \f(CW\*(C`syslog($priority,
$message)\*(C'\fR. This protects against hostile formatting sequences that
might show up if \f(CW$message\fR contains tainted data.
.IP "\fBsetlogmask($mask_priority)\fR" 4
.IX Item "setlogmask($mask_priority)"
Sets the log mask for the current process to \f(CW$mask_priority\fR and
returns the old mask. If the mask argument is 0, the current log mask
is not modified. See \*(L"Levels\*(R" for the list of available levels.
Log critical messages, errors and warnings:
\& setlogmask(LOG_CRIT|LOG_ERR|LOG_WARNING);
.IP "\fBsetlogsock($sock_type)\fR" 4
.IX Item "setlogsock($sock_type)"
.ie n .IP "\fBsetlogsock($sock_type, \fB$stream_location\fB)\fR (added in 5.004_02)" 4
.el .IP "\fBsetlogsock($sock_type, \f(CB$stream_location\fB)\fR (added in 5.004_02)" 4
.IX Item "setlogsock($sock_type, $stream_location) (added in 5.004_02)"
Sets the socket type to be used for the next call to
\&\f(CW\*(C`openlog()\*(C'\fR or \f(CW\*(C`syslog()\*(C'\fR and returns true on success,
\&\f(CW\*(C`undef\*(C'\fR on failure.
A value of \f(CW"unix"\fR will connect to the \s-1UNIX\s0 domain socket (in some
systems a character special device) returned by the \f(CW\*(C`_PATH_LOG\*(C'\fR macro
(if your system defines it), or \fI/dev/log\fR or \fI/dev/conslog\fR,
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 \s-1IRIX\s0 require \f(CW"stream"\fR instead of \f(CW"unix"\fR.)
A value of \f(CW"inet"\fR will connect to an \s-1INET\s0 socket (either \f(CW\*(C`tcp\*(C'\fR or \f(CW\*(C`udp\*(C'\fR,
tried in that order) returned by \f(CW\*(C`getservbyname()\*(C'\fR. \f(CW"tcp"\fR and \f(CW"udp"\fR can
also be given as values. The value \f(CW"console"\fR will send messages
directly to the console, as for the \f(CW"cons"\fR option in the logopts in
\&\f(CW\*(C`openlog()\*(C'\fR.
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 order.
The default is to try \f(CW\*(C`tcp\*(C'\fR, \f(CW\*(C`udp\*(C'\fR, \f(CW\*(C`unix\*(C'\fR, \f(CW\*(C`stream\*(C'\fR, \f(CW\*(C`console\*(C'\fR.
Giving an invalid value for \f(CW$sock_type\fR will croak.
.IP "\fB\f(BIcloselog()\fB\fR" 4
Closes the log file and return true on success.
\& openlog($program, 'cons,pid', 'user');
\& syslog('info', '%s', 'this is another test');
\& syslog('mail|warning', 'this is a better test: %d', time);
\& syslog('debug', 'this is the last test');
\& openlog("$program $$", 'ndelay', 'user');
\& syslog('notice', 'fooprogram: this is really done');
\& syslog('info', 'problem was %m'); # %m == $! in syslog(3)
\& # Log to UDP port on $remotehost instead of logging locally
\& $Sys::Syslog::host = $remotehost;
\& openlog($program, 'ndelay', 'user');
\& syslog('info', 'something happened over here');
.IX Subsection "Facilities"
\&\f(CW\*(C`LOG_AUTH\*(C'\fR \- security/authorization messages
\&\f(CW\*(C`LOG_AUTHPRIV\*(C'\fR \- security/authorization messages (private)
\&\f(CW\*(C`LOG_CRON\*(C'\fR \- clock daemon (\fBcron\fR and \fBat\fR)
\&\f(CW\*(C`LOG_DAEMON\*(C'\fR \- system daemons without separate facility value
\&\f(CW\*(C`LOG_FTP\*(C'\fR \- ftp daemon
\&\f(CW\*(C`LOG_KERN\*(C'\fR \- kernel messages
\&\f(CW\*(C`LOG_LOCAL0\*(C'\fR through \f(CW\*(C`LOG_LOCAL7\*(C'\fR \- reserved for local use
\&\f(CW\*(C`LOG_LPR\*(C'\fR \- line printer subsystem
\&\f(CW\*(C`LOG_MAIL\*(C'\fR \- mail subsystem
\&\f(CW\*(C`LOG_NEWS\*(C'\fR \- \s-1USENET\s0 news subsystem
\&\f(CW\*(C`LOG_SYSLOG\*(C'\fR \- messages generated internally by \fBsyslogd\fR
\&\f(CW\*(C`LOG_USER\*(C'\fR (default) \- generic user-level messages
\&\f(CW\*(C`LOG_UUCP\*(C'\fR \- \s-1UUCP\s0 subsystem
\&\f(CW\*(C`LOG_EMERG\*(C'\fR \- system is unusable
\&\f(CW\*(C`LOG_ALERT\*(C'\fR \- action must be taken immediately
\&\f(CW\*(C`LOG_CRIT\*(C'\fR \- critical conditions
\&\f(CW\*(C`LOG_ERR\*(C'\fR \- error conditions
\&\f(CW\*(C`LOG_WARNING\*(C'\fR \- warning conditions
\&\f(CW\*(C`LOG_NOTICE\*(C'\fR \- normal, but significant, condition
\&\f(CW\*(C`LOG_INFO\*(C'\fR \- informational message
\&\f(CW\*(C`LOG_DEBUG\*(C'\fR \- debug-level message
.IP "Invalid argument passed to setlogsock" 4
.IX Item "Invalid argument passed to setlogsock"
\&\fB(F)\fR You gave \f(CW\*(C`setlogsock()\*(C'\fR an invalid value for \f(CW$sock_type\fR.
.IP "no connection to syslog available" 4
.IX Item "no connection to syslog available"
\&\fB(F)\fR \f(CW\*(C`syslog()\*(C'\fR failed to connect to the specified socket.
.ie n .IP "stream passed to setlogsock, but %s is not writable" 4
.el .IP "stream passed to setlogsock, but \f(CW%s\fR is not writable" 4
.IX Item "stream passed to setlogsock, but %s is not writable"
\&\fB(W)\fR You asked \f(CW\*(C`setlogsock()\*(C'\fR to use a stream socket, but the given
.IP "stream passed to setlogsock, but could not find any device" 4
.IX Item "stream passed to setlogsock, but could not find any device"
\&\fB(W)\fR You asked \f(CW\*(C`setlogsock()\*(C'\fR to use a stream socket, but didn't
provide a path, and \f(CW\*(C`Sys::Syslog\*(C'\fR was unable to find an appropriate one.
.IP "tcp passed to setlogsock, but tcp service unavailable" 4
.IX Item "tcp passed to setlogsock, but tcp service unavailable"
\&\fB(W)\fR You asked \f(CW\*(C`setlogsock()\*(C'\fR to use a \s-1TCP\s0 socket, but the service
is not available on the system.
.ie n .IP "syslog: expecting argument %s" 4
.el .IP "syslog: expecting argument \f(CW%s\fR" 4
.IX Item "syslog: expecting argument %s"
\&\fB(F)\fR You forgot to give \f(CW\*(C`syslog()\*(C'\fR the indicated argument.
.ie n .IP "syslog: invalid level/facility: %s" 4
.el .IP "syslog: invalid level/facility: \f(CW%s\fR" 4
.IX Item "syslog: invalid level/facility: %s"
\&\fB(F)\fR You specified an invalid level or facility, like \f(CW\*(C`LOG_KERN\*(C'\fR
(which is reserved to the kernel).
.ie n .IP "syslog: too many levels given: %s" 4
.el .IP "syslog: too many levels given: \f(CW%s\fR" 4
.IX Item "syslog: too many levels given: %s"
\&\fB(F)\fR You specified too many levels.
.ie n .IP "syslog: too many facilities given: %s" 4
.el .IP "syslog: too many facilities given: \f(CW%s\fR" 4
.IX Item "syslog: too many facilities given: %s"
\&\fB(F)\fR You specified too many facilities.
.IP "syslog: level must be given" 4
.IX Item "syslog: level must be given"
\&\fB(F)\fR You forgot to specify a level.
.IP "udp passed to setlogsock, but udp service unavailable" 4
.IX Item "udp passed to setlogsock, but udp service unavailable"
\&\fB(W)\fR You asked \f(CW\*(C`setlogsock()\*(C'\fR to use a \s-1UDP\s0 socket, but the service
is not available on the system.
.IP "unix passed to setlogsock, but path not available" 4
.IX Item "unix passed to setlogsock, but path not available"
\&\fB(W)\fR You asked \f(CW\*(C`setlogsock()\*(C'\fR to use a \s-1UNIX\s0 socket, but \f(CW\*(C`Sys::Syslog\*(C'\fR
was unable to find an appropriate an appropriate device.
\&\fISyslogging with Perl\fR, <http://lexington.pm.org/meetings/022001.html>
Tom Christiansen <\fItchrist@perl.com\fR> and Larry Wall
\&\s-1UNIX\s0 domain sockets added by Sean Robinson
<\fIrobinson_s@sc.maricopa.edu\fR> with support from Tim Bunce
<\fITim.Bunce@ig.co.uk\fR> and the \f(CW\*(C`perl5\-porters\*(C'\fR mailing list.
Dependency on \fIsyslog.ph\fR replaced with \s-1XS\s0 code by Tom Hughes
Code for \f(CW\*(C`constant()\*(C'\fRs regenerated by Nicholas Clark <\fInick@ccl4.org\fR>.
Failover to different communication modes by Nick Williams
<\fINick.Williams@morganstanley.com\fR>.
Extracted from core distribution for publishing on the \s-1CPAN\s0 by
Se\*'bastien Aperghis-Tramoni <sebastien@aperghis.net>.
Please report any bugs or feature requests to
\&\f(CW\*(C`bug\-sys\-syslog at rt.cpan.org\*(C'\fR, or through the web interface at
<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Sys\-Syslog>.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
You can find documentation for this module with the perldoc command.
You can also look for information at:
.IP "* AnnoCPAN: Annotated \s-1CPAN\s0 documentation" 4
.IX Item "AnnoCPAN: Annotated CPAN documentation"
<http://annocpan.org/dist/Sys\-Syslog>
.IP "* \s-1CPAN\s0 Ratings" 4
<http://cpanratings.perl.org/d/Sys\-Syslog>
.IP "* \s-1RT:\s0 \s-1CPAN\s0's request tracker" 4
.IX Item "RT: CPAN's request tracker"
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Sys\-Syslog>
.IP "* Search \s-1CPAN\s0" 4
<http://search.cpan.org/dist/Sys\-Syslog>
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.