diff options
author | Craig Fields <cfields@mit.edu> | 1988-11-14 11:53:04 +0000 |
---|---|---|
committer | Craig Fields <cfields@mit.edu> | 1988-11-14 11:53:04 +0000 |
commit | e4806a5d430b911e4f515d2fd3b5e8f9992d7ced (patch) | |
tree | 1487ab359738886f68a4660cb3d633fa31dc2b1d /clients/syslogd | |
parent | 9e26dd85ba64dc6c49cd9c48ae4dd0bf338f51f6 (diff) |
Initial revision
Diffstat (limited to 'clients/syslogd')
-rw-r--r-- | clients/syslogd/syslog.3 | 184 | ||||
-rw-r--r-- | clients/syslogd/syslog.h | 75 |
2 files changed, 259 insertions, 0 deletions
diff --git a/clients/syslogd/syslog.3 b/clients/syslogd/syslog.3 new file mode 100644 index 0000000..8acef78 --- /dev/null +++ b/clients/syslogd/syslog.3 @@ -0,0 +1,184 @@ +.\" Copyright (c) 1983 Regents of the University of California. +.\" All rights reserved. The Berkeley software License Agreement +.\" specifies the terms and conditions for redistribution. +.\" +.\" @(#)syslog.3 6.6 (Berkeley) 5/15/86 +.\" +.TH SYSLOG 3 "May 15, 1986" +.UC 5 +.SH NAME +syslog, openlog, closelog, setlogmask \- control system log +.SH SYNOPSIS +.B "#include <syslog.h> +.PP +.B "openlog(ident, logopt, facility) +.br +.B "char *ident; +.PP +.B "syslog(priority, message, parameters ... ) +.br +.B "char *message; +.PP +.B "closelog() +.PP +.B "setlogmask(maskpri) +.SH DESCRIPTION +.I Syslog +arranges to write +.I message +onto the system log maintained by +.IR syslogd (8). +The message is tagged with +.IR priority . +The message looks like a +.IR printf (3) +string except that +.B %m +is replaced by the current error message (collected from +.IR errno ). +A trailing newline is added if needed. +This message will be read by +.IR syslogd (8) +and written to the system console, log files, or forwarded to +.I syslogd +on another host as appropriate. +.PP +Priorities are encoded as a +.I facility +and a +.IR level . +The facility describes the part of the system +generating the message. +The level is selected from an ordered list: +.IP LOG_EMERG \w'LOG_WARNING'u+3 +A panic condition. +This is normally broadcast to all users. +.IP LOG_ALERT \w'LOG_WARNING'u+3 +A condition that should be corrected immediately, +such as a corrupted system database. +.IP LOG_CRIT \w'LOG_WARNING'u+3 +Critical conditions, +e.g., hard device errors. +.IP LOG_ERR \w'LOG_WARNING'u+3 +Errors. +.IP LOG_WARNING \w'LOG_WARNING'u+3 +Warning messages. +.IP LOG_NOTICE \w'LOG_WARNING'u+3 +Conditions that are not error conditions, +but should possibly be handled specially. +.IP LOG_INFO \w'LOG_WARNING'u+3 +Informational messages. +.IP LOG_DEBUG \w'LOG_WARNING'u+3 +Messages that contain information +normally of use only when debugging a program. +.PP +If +.I syslog +cannot pass the message to +.IR syslogd , +it will attempt to write the message on +.I /dev/console +if the LOG_CONS option is set (see below). +.PP +If special processing is needed, +.I openlog +can be called to initialize the log file. +The parameter +.I ident +is a string that is prepended to every message. +.I Logopt +is a bit field indicating logging options. +Current values for +.I logopt +are: +.IP LOG_PID \w'LOG_WARNING'u+3 +log the process id with each message: +useful for identifying instantiations of daemons. +.IP LOG_CONS \w'LOG_WARNING'u+3 +Force writing messages to the console if unable to send it to +.I syslogd. +This option is safe to use in daemon processes that have no controlling +terminal since +.I syslog +will fork before opening the console. +.IP LOG_NDELAY \w'LOG_WARNING'u+3 +Open the connection to +.I 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. +.IP LOG_NOWAIT \w'LOG_WARNING'u+3 +Don't wait for children forked to log messages on the console. +This option should be used by processes that enable notification +of child termination via SIGCHLD, as +.I syslog +may otherwise block waiting for a child whose exit status has already +been collected. +.PP +The +.I facility +parameter encodes a default facility to be assigned to all messages +that do not have an explicit facility encoded: +.IP LOG_KERN \w'LOG_WARNING'u+3 +Messages generated by the kernel. +These cannot be generated by any user processes. +.IP LOG_USER \w'LOG_WARNING'u+3 +Messages generated by random user processes. +This is the default facility identifier if none is specified. +.IP LOG_MAIL \w'LOG_WARNING'u+3 +The mail system. +.IP LOG_DAEMON \w'LOG_WARNING'u+3 +System daemons, such as +.IR ftpd (8), +.IR routed (8), +etc. +.IP LOG_AUTH \w'LOG_WARNING'u+3 +The authorization system: +.IR login (1), +.IR su (1), +.IR getty (8), +etc. +.IP LOG_LPR \w'LOG_WARNING'u+3 +The line printer spooling system: +.IR lpr (1), +.IR lpc (8), +.IR lpd (8), +etc. +.IP LOG_LOCAL0 \w'LOG_WARNING'u+3 +Reserved for local use. +Similarly for LOG_LOCAL1 through LOG_LOCAL7. +.PP +.I Closelog +can be used to close the log file. +.PP +.I Setlogmask +sets the log priority mask to +.I maskpri +and returns the previous mask. +Calls to +.I syslog +with a priority not set in +.I maskpri +are rejected. +The mask for an individual priority +.I pri +is calculated by the macro LOG_MASK(\fIpri\fP); +the mask for all priorities up to and including +.I toppri +is given by the macro LOG_UPTO(\fItoppri\fP). +The default allows all priorities to be logged. +.SH EXAMPLES +.nf +syslog(LOG_ALERT, "who: internal error 23"); + +openlog("ftpd", LOG_PID, LOG_DAEMON); +setlogmask(LOG_UPTO(LOG_ERR)); +syslog(LOG_INFO, "Connection from host %d", CallingHost); + +syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m"); +.fi +.SH "SEE ALSO" +logger(1), +syslogd(8) diff --git a/clients/syslogd/syslog.h b/clients/syslogd/syslog.h new file mode 100644 index 0000000..139742c --- /dev/null +++ b/clients/syslogd/syslog.h @@ -0,0 +1,75 @@ +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + * + * @(#)syslog.h 7.8 (Berkeley) 5/26/88 + */ + +/* + * Facility codes + */ + +#define LOG_KERN (0<<3) /* kernel messages */ +#define LOG_USER (1<<3) /* random user-level messages */ +#define LOG_MAIL (2<<3) /* mail system */ +#define LOG_DAEMON (3<<3) /* system daemons */ +#define LOG_AUTH (4<<3) /* security/authorization messages */ +#define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */ +#define LOG_LPR (6<<3) /* line printer subsystem */ +#define LOG_NEWS (7<<3) /* network news subsystem */ +#define LOG_UUCP (8<<3) /* UUCP subsystem */ + /* other codes through 15 reserved for system use */ +#define LOG_LOCAL0 (16<<3) /* reserved for local use */ +#define LOG_LOCAL1 (17<<3) /* reserved for local use */ +#define LOG_LOCAL2 (18<<3) /* reserved for local use */ +#define LOG_LOCAL3 (19<<3) /* reserved for local use */ +#define LOG_LOCAL4 (20<<3) /* reserved for local use */ +#define LOG_LOCAL5 (21<<3) /* reserved for local use */ +#define LOG_LOCAL6 (22<<3) /* reserved for local use */ +#define LOG_LOCAL7 (23<<3) /* reserved for local use */ + +#define LOG_NFACILITIES 24 /* maximum number of facilities */ +#define LOG_FACMASK 0x03f8 /* mask to extract facility part */ + +#define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) /* facility of pri */ + +/* + * Priorities (these are ordered) + */ + +#define LOG_EMERG 0 /* system is unusable */ +#define LOG_ALERT 1 /* action must be taken immediately */ +#define LOG_CRIT 2 /* critical conditions */ +#define LOG_ERR 3 /* error conditions */ +#define LOG_WARNING 4 /* warning conditions */ +#define LOG_NOTICE 5 /* normal but signification condition */ +#define LOG_INFO 6 /* informational */ +#define LOG_DEBUG 7 /* debug-level messages */ + +#define LOG_PRIMASK 0x0007 /* mask to extract priority part (internal) */ +#define LOG_PRI(p) ((p) & LOG_PRIMASK) /* extract priority */ + +#define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri)) + +#ifdef KERNEL +#define LOG_PRINTF -1 /* pseudo-priority to indicate use of printf */ +#endif + +/* + * arguments to setlogmask. + */ +#define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */ +#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */ + +/* + * Option flags for openlog. + * + * LOG_ODELAY no longer does anything; LOG_NDELAY is the + * inverse of what it used to be. + */ +#define LOG_PID 0x01 /* log the pid with each message */ +#define LOG_CONS 0x02 /* log on the console if errors in sending */ +#define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */ +#define LOG_NDELAY 0x08 /* don't delay open */ +#define LOG_NOWAIT 0x10 /* if forking to log on console, don't wait() */ |