SYSLOG(3lua)

SYSLOG(3lua) | LUA Library Manual | SYSLOG(3lua)

# NAME

`syslog` —
access syslog(3) functionality from Lua

# SYNOPSIS

`local syslog = require 'syslog'`

`syslog.openlog(ident, logopt, facility)`
`syslog.syslog(priority, message)`
`syslog.closelog()`
`oldmask = syslog.setlogmask(maskpri)`

# DESCRIPTION

The `syslog` Lua binding provides access to the syslog(3) functionality.

`syslog.openlog(ident, logopt, facility)`
  The syslog.openlog() function provides for more specialized processing of the messages sent by syslog.syslog(). The parameter ident is a string that will be prepended to every message. The logopt argument is a bit field specifying logging options, which is formed by adding one or more of the following values:

  `syslog.LOG_CONS`
    If `syslog.syslog`() cannot pass the message to syslogd(8) it will attempt to write the message to the console (``/dev/console'').

  `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.

  `syslog.LOG_PERROR`
    Write the message to standard error output as well to the system log.

  `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.)

  The facility parameter encodes a default facility to be assigned to all messages that do not have an explicit facility encoded:

  `syslog.LOG_AUTH`
    The authorization system: login(1), su(1), getty(8), etc.

  `syslog.LOG_AUTHPRIV`
    The same as LOG_AUTH, but logged to a file readable only by selected individuals.

  `syslog.LOG_CRON`
    The cron daemon: cron(8).

  `syslog.LOG_DAEMON`
    System daemons, such as routed(8), that are not provided for explicitly by other facilities.

  `syslog.LOG_FTP`
    The file transfer protocol daemon: ftpd(8).

  `syslog.LOG_KERN`
    Messages generated by the kernel. These cannot be generated by any user processes.

  `syslog.LOG_LPR`
    The line printer spooling system: lpr(1), lpc(8), lpd(8), etc.

  `syslog.LOG_MAIL`
    The mail system.

  `syslog.LOG_NEWS`
    The network news system.

  `syslog.LOG_SYSLOG`
    Messages generated internally by syslogd(8).

  `syslog.LOG_USER`
    Messages generated by random user processes. This is the default facility identifier if none is specified.

  `syslog.LOG_UUCP`
    The uucp system.

  `syslog.LOG_LOCAL0`
    Reserved for local use. Similarly for syslog.LOG_LOCAL1 through syslog.LOG_LOCAL7

`syslog.syslog(priority, message)`
  The `syslog`() function writes 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)).

  The message is tagged with priority. Priorities are encoded as a facility and a level. The facility describes the part of the system generating the message. The level is selected from the following ordered (high to low) list:

  `syslog.LOG_EMERG`
    A panic condition. This is normally broadcast to all users.

  `syslog.LOG_ALERT`
    A condition that should be corrected immediately, such as a corrupted system database.

  `syslog.LOG_CRIT`
    Critical conditions, e.g., hard device errors.

  `syslog.LOG_ERR`
    Errors.

  `syslog.LOG_WARNING`
    Warning messages.

  `syslog.LOG_NOTICE`
    Conditions that are not error conditions, but should possibly be handled specially.

  `syslog.LOG_INFO`
    Informational messages.

  `syslog.LOG_DEBUG`
    Messages that contain information normally of use only when debugging a program.

`syslog.closelog()`
  The `syslog.closelog`() function can be used to close the log file.

`oldmask = syslog.setlogmask(maskpri)`
  The `setlogmask`() function sets the log priority mask to maskpri and returns the previous mask. Calls to `syslog`() with a priority not set in maskpri are rejected.

# SEE ALSO

lua(1), luac(1), syslog(3), intro(3lua), syslogd(8)

# HISTORY

A `syslog` Lua binding manual appeared in NetBSD 7.0.

# AUTHORS

The `syslog` Lua binding was written by Marc Balmer <mbalmer@NetBSD.org>.

January 7, 2014 | NetBSD 10.0