📄 sys::syslog.3
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...de Sp \" Vertical space (when we can't use .PP).if t .sp .5v.if n .sp...de Vb \" Begin verbatim text.ft CW.nf.ne \\$1...de Ve \" End verbatim text.ft R.fi...\" 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. \*(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<>..tr \(*W-.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'.ie n \{\. ds -- \(*W-. ds PI pi. 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. ds L" "". ds R" "". ds C` "". ds C' ""'br\}.el\{\. ds -- \|\(em\|. ds PI \(*p. ds L" ``. ds R" '''br\}.\".\" Escape single quotes in literal strings from groff's Unicode transform..ie \n(.g .ds Aq \(aq.el .ds Aq '.\".\" 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..ie \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.el \{\. de IX...\}.\".\" 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.if n \{\. ds #H 0. ds #V .8m. ds #F .3m. ds #[ \f1. ds #] \fP.\}.if t \{\. ds #H ((1u-(\\\\n(.fu%2u))*.13m). ds #V .6m. ds #F 0. ds #[ \&. ds #] \&.\}. \" simple accents for nroff and troff.if n \{\. ds ' \&. ds ` \&. ds ^ \&. ds , \&. ds ~ ~. ds /.\}.if t \{\. 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 \\{\. ds : e. ds 8 ss. ds o a. ds d- d\h'-1'\(ga. ds D- D\h'-1'\(hy. ds th \o'bp'. ds Th \o'LP'. ds ae ae. ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "Sys::Syslog 3".TH Sys::Syslog 3 "2007-12-18" "perl v5.10.0" "Perl Programmers Reference Guide".\" For nroff, turn off justification. Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..if n .ad l.nh.SH "NAME"Sys::Syslog \- Perl interface to the UNIX syslog(3) calls.SH "VERSION".IX Header "VERSION"Version 0.22.SH "SYNOPSIS".IX Header "SYNOPSIS".Vb 3\& 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\&\& openlog $ident, $logopt, $facility; # don\*(Aqt forget this\& syslog $priority, $format, @args;\& $oldmask = setlogmask $mask_priority;\& closelog;.Ve.SH "DESCRIPTION".IX Header "DESCRIPTION"\&\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 argsjust like \f(CWsyslog(3)\fR..PPYou can find a kind of \s-1FAQ\s0 in \*(L"\s-1THE\s0 \s-1RULES\s0 \s-1OF\s0 \s-1SYS::SYSLOG\s0\*(R". Please read it before coding, and again before asking questions..SH "EXPORTS".IX Header "EXPORTS"\&\f(CW\*(C`Sys::Syslog\*(C'\fR exports the following \f(CW\*(C`Exporter\*(C'\fR tags:.IP "\(bu" 4\&\f(CW\*(C`:standard\*(C'\fR exports the standard \f(CWsyslog(3)\fR functions:.Sp.Vb 1\& openlog closelog setlogmask syslog.Ve.IP "\(bu" 4\&\f(CW\*(C`:extended\*(C'\fR exports the Perl specific functions for \f(CWsyslog(3)\fR:.Sp.Vb 1\& setlogsock.Ve.IP "\(bu" 4\&\f(CW\*(C`:macros\*(C'\fR exports the symbols corresponding to most of your \f(CWsyslog(3)\fR macros and the \f(CW\*(C`LOG_UPTO()\*(C'\fR and \f(CW\*(C`LOG_MASK()\*(C'\fR functions. See \*(L"\s-1CONSTANTS\s0\*(R" for the supported constants and their meaning..PPBy default, \f(CW\*(C`Sys::Syslog\*(C'\fR exports the symbols from the \f(CW\*(C`:standard\*(C'\fR tag..SH "FUNCTIONS".IX Header "FUNCTIONS".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)"Opens the syslog.\&\f(CW$ident\fR is prepended to every message. \f(CW$logopt\fR contains zero ormore of the options detailed below. \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 \*(L"Facilities\*(R" for a list of well-known facilities, and your \&\f(CWsyslog(3)\fR documentation for the facilities available in your system. Check \*(L"\s-1SEE\s0 \s-1ALSO\s0\*(R" for useful links. Facility can be given as a string or a numeric macro..SpThis function will croak if it can't connect to the syslog daemon..SpNote that \f(CW\*(C`openlog()\*(C'\fR now takes three arguments, just like \f(CWopenlog(3)\fR..Sp\&\fBYou should use \f(CB\*(C`openlog()\*(C'\fB before calling \f(CB\*(C`syslog()\*(C'\fB.\fR.Sp\&\fBOptions\fR.RS 4.IP "\(bu" 4\&\f(CW\*(C`cons\*(C'\fR \- This option is ignored, since the failover mechanism will drop down to the console automatically if all other media fail..IP "\(bu" 4\&\f(CW\*(C`ndelay\*(C'\fR \- Open the connection immediately (normally, the connection isopened when the first message is logged)..IP "\(bu" 4\&\f(CW\*(C`nofatal\*(C'\fR \- When set to true, \f(CW\*(C`openlog()\*(C'\fR and \f(CW\*(C`syslog()\*(C'\fR will only emit warnings instead of dying if the connection to the syslog can't be established..IP "\(bu" 4\&\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 childprocess, so this option has no effect on Linux.).IP "\(bu" 4\&\f(CW\*(C`perror\*(C'\fR \- Write the message to standard error output as well to thesystem log..IP "\(bu" 4\&\f(CW\*(C`pid\*(C'\fR \- Include \s-1PID\s0 with each message..RE.RS 4.Sp\&\fBExamples\fR.SpOpen 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:.Sp.Vb 1\& openlog($name, "ndelay,pid", "local0");.Ve.SpSame thing, but this time using the macro corresponding to \f(CW\*(C`LOCAL0\*(C'\fR:.Sp.Vb 1\& openlog($name, "ndelay,pid", LOG_LOCAL0);.Ve.RE.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)".PD 0.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)".PDIf \f(CW$priority\fR permits, logs \f(CW$message\fR or \f(CW\*(C`sprintf($format, @args)\*(C'\fRwith 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)..Sp\&\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. When using the \f(CW\*(C`eventlog\*(C'\fRmechanism, priorities \f(CW\*(C`DEBUG\*(C'\fR and \f(CW\*(C`INFO\*(C'\fR are mapped to event type \&\f(CW\*(C`informational\*(C'\fR, \f(CW\*(C`NOTICE\*(C'\fR and \f(CW\*(C`WARNIN\*(C'\fR to \f(CW\*(C`warning\*(C'\fR and \f(CW\*(C`ERR\*(C'\fR to \&\f(CW\*(C`EMERG\*(C'\fR to \f(CW\*(C`error\*(C'\fR..SpIf 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..Sp\&\fBExamples\fR.Sp.Vb 2\& 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.Ve.RS 4.IP "\fBNote\fR" 4.IX Item "Note"\&\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 argumentswere 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 thatmight show up if \f(CW$message\fR contains tainted data..RE.RS 4.RE.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. You can use the \f(CW\*(C`LOG_UPTO()\*(C'\fR function to allow all levels up to a given priority (but it only accept the numeric macros as arguments)..Sp\&\fBExamples\fR.SpOnly log errors:.Sp.Vb 1\& setlogmask( LOG_MASK(LOG_ERR) );.Ve.SpLog everything except informational messages:.Sp.Vb 1\& setlogmask( ~(LOG_MASK(LOG_INFO)) );.Ve.SpLog critical messages, errors and warnings:.Sp.Vb 1\& setlogmask( LOG_MASK(LOG_CRIT) | LOG_MASK(LOG_ERR) | LOG_MASK(LOG_WARNING) );.Ve.SpLog all messages up to debug:.Sp.Vb 1\& setlogmask( LOG_UPTO(LOG_DEBUG) );.Ve.IP "\fBsetlogsock($sock_type)\fR" 4.IX Item "setlogsock($sock_type)".PD 0.ie n .IP "\fBsetlogsock($sock_type, \fB$stream_location\fB)\fR (added in Perl 5.004_02)" 4.el .IP "\fBsetlogsock($sock_type, \f(CB$stream_location\fB)\fR (added in Perl 5.004_02)" 4.IX Item "setlogsock($sock_type, $stream_location) (added in Perl 5.004_02)".PDSets 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. The available mechanisms are:.RS 4.IP "\(bu" 4\&\f(CW"native"\fR \- use the native C functions from your \f(CWsyslog(3)\fR library(added in \f(CW\*(C`Sys::Syslog\*(C'\fR 0.15)..IP "\(bu" 4\&\f(CW"eventlog"\fR \- send messages to the Win32 events logger (Win32 only; added in \f(CW\*(C`Sys::Syslog\*(C'\fR 0.19)..IP "\(bu" 4\&\f(CW"tcp"\fR \- connect to a \s-1TCP\s0 socket, on the \f(CW\*(C`syslog/tcp\*(C'\fR or \f(CW\*(C`syslogng/tcp\*(C'\fR service..IP "\(bu" 4\&\f(CW"udp"\fR \- connect to a \s-1UDP\s0 socket, on the \f(CW\*(C`syslog/udp\*(C'\fR service..IP "\(bu" 4\&\f(CW"inet"\fR \- connect to an \s-1INET\s0 socket, either \s-1TCP\s0 or \s-1UDP\s0, tried in that order..IP "\(bu" 4\&\f(CW"unix"\fR \- connect to a \s-1UNIX\s0 domain socket (in some systems a character special device). The name of that socket is the second parameter or, if you omit the second parameter, the value 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..IP "\(bu" 4\&\f(CW"stream"\fR \- connect to the stream indicated by the pathname provided as the optional second parameter, or, if omitted, to \fI/dev/conslog\fR. For example Solaris and \s-1IRIX\s0 system may prefer \f(CW"stream"\fR instead of \f(CW"unix"\fR..IP "\(bu" 4\&\f(CW"pipe"\fR \- connect to the named pipe indicated by the pathname provided as the optional second parameter, or, if omitted, to the value returned by the \f(CW\*(C`_PATH_LOG\*(C'\fR macro (if your system defines it), or \fI/dev/log\fR
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -