NetBSD/share/man/man3lua/syslog.3lua

218 lines
6.1 KiB
Plaintext

.\" $NetBSD: syslog.3lua,v 1.3 2014/01/07 21:54:17 mbalmer Exp $
.\"
.\" Copyright (c) 2013, 2014 Marc Balmer <mbalmer@NetBSD.org>.
.\" All rights reserved.
.\"
.\" 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. 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.
.\"
.\" 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.
.\"
.\"
.Dd January 7, 2014
.Dt SYSLOG 3lua
.Os
.Sh NAME
.Nm syslog
.Nd access
.Xr syslog 3
functionality from Lua
.Sh SYNOPSIS
.Cd "local syslog = require 'syslog'"
.Pp
.Bl -tag -width XXXX -compact
.It Dv syslog.openlog(ident, logopt, facility)
.It Dv syslog.syslog(priority, message)
.It Dv syslog.closelog()
.It Dv oldmask = syslog.setlogmask(maskpri)
.El
.Sh DESCRIPTION
The
.Nm
Lua binding provides access to the
.Xr syslog 3
funcionality.
.Pp
.Bl -tag -width XXXX -compact
.Pp
.It Dv syslog.openlog(ident, logopt, facility)
The syslog.openlog() function provides for more specialized processing of the
messages sent by syslog.syslog().
The parameter
.Ar ident
is a string that will be prepended to every message.
The
.Ar logopt
argument is a bit field specifying logging options, which is formed
by adding one or more of the following values:
.Pp
.Bl -tag -width XXXX -compact
.It Dv syslog.LOG_CONS
If
.Fn syslog.syslog
cannot pass the message to syslogd(8) it will attempt to write the
message to the console (``/dev/console'').
.Pp
.It Dv syslog.LOG_NDELAY
Open the connection to syslogd(8) 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.
.Pp
.It Dv syslog.LOG_PERROR
Write the message to standard error output as well to the system log.
.Pp
.It Dv syslog.LOG_PID
Log the process id with each message: useful for identifying instantiations of
daemons.
(This PID is placed within brackets between the ident and the message.)
.El
.Pp
The facility parameter encodes a default facility to be assigned to all
messages that do not have an explicit facility encoded:
.Pp
.Bl -tag -width XXXX -compact
.It Dv syslog.LOG_AUTH
The authorization system: login(1), su(1), getty(8), etc.
.Pp
.It Dv syslog.LOG_AUTHPRIV
The same as LOG_AUTH, but logged to a file readable only by selected
individuals.
.Pp
.It Dv syslog.LOG_CRON
The cron daemon: cron(8).
.Pp
.It Dv syslog.LOG_DAEMON
System daemons, such as routed(8), that are not provided for explicitly by other
facilities.
.Pp
.It Dv syslog.LOG_FTP
The file transfer protocol daemon: ftpd(8).
.Pp
.It Dv syslog.LOG_KERN
Messages generated by the kernel.
These cannot be generated by any user processes.
.Pp
.It Dv syslog.LOG_LPR
The line printer spooling system: lpr(1), lpc(8), lpd(8), etc.
.Pp
.It Dv syslog.LOG_MAIL
The mail system.
.Pp
.It Dv syslog.LOG_NEWS
The network news system.
.Pp
.It Dv syslog.LOG_SYSLOG
Messages generated internally by syslogd(8).
.Pp
.It Dv syslog.LOG_USER
Messages generated by random user processes.
This is the default facility identifier if none is specified.
.Pp
.It Dv syslog.LOG_UUCP
The uucp system.
.Pp
.It Dv syslog.LOG_LOCAL0
Reserved for local use.
Similarly for syslog.LOG_LOCAL1 through syslog.LOG_LOCAL7
.El
.Pp
.It Dv syslog.syslog(priority, message)
The
.Fn syslog
function writes
.Ar message
to the system message logger.
The message is then written to the system console, log files, logged-in
users, or forwarded to other machines as appropriate (see syslogd(8)).
.Pp
The
.Ar message
is tagged with
.Ar priority .
Priorities are encoded as a
.Ar facility
and a
.Ar level .
The facility describes the part of the system generating the message.
The level is selected from the following ordered (high to low) list:
.Pp
.Bl -tag -width XXXX -compact
.It Dv syslog.LOG_EMERG
A panic condition.
This is normally broadcast to all users.
.Pp
.It Dv syslog.LOG_ALERT
A condition that should be corrected immediately, such as a corrupted system
database.
.Pp
.It Dv syslog.LOG_CRIT
Critical conditions, e.g., hard device errors.
.Pp
.It Dv syslog.LOG_ERR
Errors.
.Pp
.It Dv syslog.LOG_WARNING
Warning messages.
.Pp
.It Dv syslog.LOG_NOTICE
Conditions that are not error conditions, but should possibly be handled
specially.
.Pp
.It Dv syslog.LOG_INFO
Informational messages.
.Pp
.It Dv syslog.LOG_DEBUG
Messages that contain information normally of use only when debugging a program.
.El
.Pp
.It Dv syslog.closelog()
The
.Fn syslog.closelog
function can be used to close the log file.
.Pp
.It Dv oldmask = syslog.setlogmask(maskpri)
The
.Fn setlogmask
function sets the log priority mask to maskpri and returns the previous mask.
Calls to
.Fn syslog
with a priority not set in maskpri are rejected.
.El
.Sh SEE ALSO
.Xr lua 1 ,
.Xr luac 1 ,
.Xr syslog 3 ,
.Xr intro 3lua ,
.Xr syslogd 8
.Sh HISTORY
A
.Nm
Lua binding manual appeared in
.Nx 7.0 .
.Sh AUTHORS
.An -nosplit
The
.Nm
Lua binding was written by
.An Marc Balmer Aq Mt mbalmer@NetBSD.org .