BSD 4_3_Net_2 release
[unix-history] / usr / src / lib / libc / gen / syslog.3
index 116e4c2..9af3c2a 100644 (file)
-.\" Copyright (c) 1985 The Regents of the University of California.
+.\" Copyright (c) 1985, 1991 The Regents of the University of California.
 .\" All rights reserved.
 .\"
 .\" All rights reserved.
 .\"
-.\" %sccs.include.redist.man%
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\"    must display the following acknowledgement:
+.\"    This product includes software developed by the University of
+.\"    California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
 .\"
 .\"
-.\"    @(#)syslog.3    6.16 (Berkeley) %G%
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
 .\"
 .\"
-.TH SYSLOG 3 ""
-.UC 5
-.SH NAME
-syslog, vsyslog, openlog, closelog, setlogmask \- control system log
-.SH SYNOPSIS
-.nf
-.ft B
-#include <syslog.h>
-void
-syslog(int priority, char *message, [, arg ] ... );
-
-#include <varargs.h>
-void
-vsyslog(int priority, char *message, va_list args);
-
-void
-openlog(char *ident, int logopt, int facility);
-
-void
-closelog(void);
-
-setlogmask(int maskpri);
-.ft R
-.fi
-.SH DESCRIPTION
-.I Syslog
+.\"     @(#)syslog.3   6.17 (Berkeley) 4/19/91
+.\"
+.Dd April 19, 1991
+.Dt SYSLOG 3
+.Os BSD 4.2
+.Sh NAME
+.Nm syslog ,
+.Nm vsyslog ,
+.Nm openlog ,
+.Nm closelog ,
+.Nm setlogmask
+.Nd control system log
+.Sh SYNOPSIS
+.Fd #include <syslog.h>
+.Fd #include <varargs.h>
+.Ft void
+.Fn syslog "int priority" "const char *message" "..."
+.Ft void
+.Fn vsyslog "int priority" "const char *message" "va_list args"
+.Ft void
+.Fn openlog "const char *ident" "int logopt" "int facility"
+.Ft void
+.Fn closelog void
+.Ft int
+.Fn setlogmask "int maskpri"
+.Sh DESCRIPTION
+The
+.Fn syslog
+function
 writes
 writes
-.I message
+.Fa message
 to the system message logger.
 to the system message logger.
-The message will then be written to the system console, log files,
-logged-in users, or forwarded to other machines as appropriate (see
-.IR syslogd (8)).
-.PP
+The message is then written to the system console, log files,
+logged-in users, or forwarded to other machines as appropriate. (See
+.Xr syslogd 8 . )
+.Pp
 The message is identical to a
 The message is identical to a
-.IR printf (3)
-format string, except that ``%m'' is replaced by the current error
-message (as denoted by
-.IR errno ;
+.Xr printf 3
+format string, except that
+.Ql %m
+is replaced by the current error
+message. (As denoted by the global variable
+.Va errno ;
 see
 see
-.IR strerror (3)).
+.Xr strerror 3 . )
 A trailing newline is added if none is present.
 A trailing newline is added if none is present.
-.PP
-.I Vsyslog
+.Pp
+The
+.Fn vsyslog
+function
 is an alternate form in which the arguments have already been captured
 using the variable-length argument facilities of
 is an alternate form in which the arguments have already been captured
 using the variable-length argument facilities of
-.IR varargs (3).
-.PP
+.Xr varargs 3 .
+.Pp
 The message is tagged with
 The message is tagged with
-.IR priority .
+.Fa priority .
 Priorities are encoded as a
 Priorities are encoded as a
-.I facility
+.Fa facility
 and a
 and a
-.IR level .
+.Em level .
 The facility describes the part of the system
 generating the message.
 The level is selected from the following
 The facility describes the part of the system
 generating the message.
 The level is selected from the following
-.B ordered
+.Em ordered
 (high to low) list:
 (high to low) list:
-.TP
-LOG_EMERG
+.Bl -tag -width LOG_AUTHPRIV
+.It Dv LOG_EMERG
 A panic condition.
 This is normally broadcast to all users.
 A panic condition.
 This is normally broadcast to all users.
-.TP
-LOG_ALERT
+.It Dv LOG_ALERT
 A condition that should be corrected immediately, such as a corrupted
 system database.
 A condition that should be corrected immediately, such as a corrupted
 system database.
-.TP
-LOG_CRIT
+.It Dv LOG_CRIT
 Critical conditions, e.g., hard device errors.
 Critical conditions, e.g., hard device errors.
-.TP
-LOG_ERR
+.It Dv LOG_ERR
 Errors.
 Errors.
-.TP
-LOG_WARNING
+.It Dv LOG_WARNING
 Warning messages.
 Warning messages.
-.TP
-LOG_NOTICE
+.It Dv LOG_NOTICE
 Conditions that are not error conditions,
 but should possibly be handled specially.
 Conditions that are not error conditions,
 but should possibly be handled specially.
-.TP
-LOG_INFO
+.It Dv LOG_INFO
 Informational messages.
 Informational messages.
-.TP
-LOG_DEBUG
+.It Dv LOG_DEBUG
 Messages that contain information
 normally of use only when debugging a program.
 Messages that contain information
 normally of use only when debugging a program.
-.PP
-.I Openlog
+.El
+.Pp
+The
+.Fn openlog
+function
 provides for more specialized processing of the messages sent
 by
 provides for more specialized processing of the messages sent
 by
-.I syslog
+.Fn syslog
 and
 and
-.IR vsyslog .
+.Fn vsyslog .
 The parameter
 The parameter
-.I ident
+.Fa ident
 is a string that will be prepended to every message.
 is a string that will be prepended to every message.
-.I Logopt
+The
+.Fa logopt
+argument
 is a bit field specifying logging options, which is formed by
 is a bit field specifying logging options, which is formed by
-.IR OR 'ing
+.Tn OR Ns 'ing
 one or more of the following values:
 one or more of the following values:
-.TP
-LOG_CONS
+.Bl -tag -width LOG_AUTHPRIV
+.It Dv LOG_CONS
 If
 If
-.I syslog
+.Fn syslog
 cannot pass the message to
 cannot pass the message to
-.I syslogd
-it will attempt to write the message to the console (``/dev/console'').
-.TP
-LOG_NDELAY 
+.Xr syslogd
+it will attempt to write the message to the console
+.Pq Dq Pa /dev/console.
+.It Dv LOG_NDELAY 
 Open the connection to
 Open the connection to
-.I syslogd
+.Xr syslogd
 immediately.
 Normally the open is delayed until the first message is logged.
 Useful for programs that need to manage the order in which file
 descriptors are allocated.
 immediately.
 Normally the open is delayed until the first message is logged.
 Useful for programs that need to manage the order in which file
 descriptors are allocated.
-.TP
-LOG_PERROR
+.It Dv LOG_PERROR
 Write the message to standard error output as well to the system log.
 Write the message to standard error output as well to the system log.
-.TP
-LOG_PID
+.It Dv LOG_PID
 Log the process id with each message: useful for identifying
 instantiations of daemons.
 Log the process id with each message: useful for identifying
 instantiations of daemons.
-.PP
+.El
+.Pp
 The
 The
-.I facility
+.Fa facility
 parameter encodes a default facility to be assigned to all messages
 that do not have an explicit facility encoded:
 parameter encodes a default facility to be assigned to all messages
 that do not have an explicit facility encoded:
-.TP
-LOG_AUTH
+.Bl -tag -width LOG_AUTHPRIV
+.It Dv LOG_AUTH
 The authorization system:
 The authorization system:
-.IR login (1),
-.IR su (1),
-.IR getty (8),
+.Xr login 1 ,
+.Xr su 1 ,
+.Xr getty 8 ,
 etc.
 etc.
-.TP
-LOG_AUTHPRIV
-The same as LOG_AUTH, but logged to a file readable only by
+.It Dv LOG_AUTHPRIV
+The same as
+.Dv LOG_AUTH ,
+but logged to a file readable only by
 selected individuals.
 selected individuals.
-.TP
-LOG_CRON
+.It Dv LOG_CRON
 The clock daemon.
 The clock daemon.
-.TP
-LOG_DAEMON
+.It Dv LOG_DAEMON
 System daemons, such as
 System daemons, such as
-.IR ftpd (8),
-.IR routed (8),
+.Xr ftpd 8 ,
+.Xr routed 8 ,
 etc., that are not provided for explicitly by other facilities.
 etc., that are not provided for explicitly by other facilities.
-.TP
-LOG_KERN
+.It Dv LOG_KERN
 Messages generated by the kernel.
 These cannot be generated by any user processes.
 Messages generated by the kernel.
 These cannot be generated by any user processes.
-.TP
-LOG_LPR
+.It Dv LOG_LPR
 The line printer spooling system:
 The line printer spooling system:
-.IR lpr (1),
-.IR lpc (8),
-.IR lpd (8),
+.Xr lpr 1 ,
+.Xr lpc 8 ,
+.Xr lpd 8 ,
 etc.
 etc.
-.TP
-LOG_MAIL
+.It Dv LOG_MAIL
 The mail system.
 The mail system.
-.TP
-LOG_NEWS
+.It Dv LOG_NEWS
 The network news system.
 The network news system.
-.TP
-LOG_SYSLOG
+.It Dv LOG_SYSLOG
 Messages generated internally by
 Messages generated internally by
-.IR syslogd (8).
-.TP
-LOG_USER
+.Xr syslogd 8 .
+.It Dv LOG_USER
 Messages generated by random user processes.
 This is the default facility identifier if none is specified.
 Messages generated by random user processes.
 This is the default facility identifier if none is specified.
-.TP
-LOG_UUCP
+.It Dv LOG_UUCP
 The uucp system.
 The uucp system.
-.TP
-LOG_LOCAL0
+.It Dv LOG_LOCAL0
 Reserved for local use.
 Reserved for local use.
-Similarly for LOG_LOCAL1 through LOG_LOCAL7.
-.PP
-.I Closelog
+Similarly for
+.Dv LOG_LOCAL1
+through
+.Dv LOG_LOCAL7 .
+.El 
+.Pp
+The
+.Fn closelog
+function
 can be used to close the log file.
 can be used to close the log file.
-.PP
-.I Setlogmask
+.Pp
+The
+.Fn setlogmask
+function
 sets the log priority mask to
 sets the log priority mask to
-.I maskpri
+.Fa maskpri
 and returns the previous mask.
 Calls to
 and returns the previous mask.
 Calls to
-.I syslog
+.Fn syslog
 with a priority not set in
 with a priority not set in
-.I maskpri
+.Fa maskpri
 are rejected.
 The mask for an individual priority
 are rejected.
 The mask for an individual priority
-.I pri
-is calculated by the macro ``LOG_MASK(pri);''
+.Fa pri
+is calculated by the macro
+.Fn LOG_MASK pri ;
 the mask for all priorities up to and including
 the mask for all priorities up to and including
-.I toppri
-is given by the macro ``LOG_UPTO(toppri);''.
+.Fa toppri
+is given by the macro
+.Fn LOG_UPTO toppri ; .
 The default allows all priorities to be logged.
 The default allows all priorities to be logged.
-.SH EXAMPLES
-.nf
-.RS
+.Sh RETURN VALUES
+The routines
+.Fn closelog ,
+.Fn openlog ,
+.Fn syslog
+and
+.Fn vsyslog
+return no value.
+.Pp
+The routine
+.Fn setlogmask
+always returns the previous log mask level.
+.Sh EXAMPLES
+.Bd -literal -offset indent -compact
 syslog(LOG_ALERT, "who: internal error 23");
 
 openlog("ftpd", LOG_PID, LOG_DAEMON);
 syslog(LOG_ALERT, "who: internal error 23");
 
 openlog("ftpd", LOG_PID, LOG_DAEMON);
@@ -214,19 +254,11 @@ setlogmask(LOG_UPTO(LOG_ERR));
 syslog(LOG_INFO, "Connection from host %d", CallingHost);
 
 syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m");
 syslog(LOG_INFO, "Connection from host %d", CallingHost);
 
 syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m");
-.RE
-.fi
-.SH RETURNS
-The routines
-.IR closelog ,
-.IR openlog ,
-.IR syslog
-and
-.I vsyslog
-return no value.
-.PP
-The routine
-.I setlogmask
-always returns the previous log mask level.
-.SH "SEE ALSO"
-logger(1), syslogd(8)
+.Ed
+.Sh SEE ALSO
+.Xr logger 1 ,
+.Xr syslogd 8
+.Sh HISTORY
+These
+functions appeared in 
+.Bx 4.2 .