Home Contents | # os.openlog | OS | Core4 Lua Commands

## SYNOPSIS

#include <lua/syslog.h>

1. os.openlog(ident, option, facility)
2. os.syslog([pri,] message)
3. os.closelog()

## DESCRIPTION

This is the complete documentation of the syslog features. Most applications make do with using only the os.syslog() function alone.

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

LOG_CONS | Not implemented on Core 4
LOG_NDELAY | Open the connection to the system message logger 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.
LOG_PERROR | Write the message to standard error output as well as to the system log.
LOG_PID | Log the process ID with each message; useful for identifying instantiations of daemons.

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

LOG_AUTH | The authorization system: login(1), su(1), getty(8), etc.
LOG_AUTHPRIV | The same as LOG_AUTH, but logged to a file readable only by selected individuals.
LOG_DAEMON | System daemons, such as dhcpd, that are not provided for explicitly by other facilities.
LOG_KERN | Messages generated by the kernel.
LOG_MAIL | The mail system.
LOG_SYSLOG | Messages generated internally by syslog.
LOG_USER | Messages generated by random user processes. This is the default facility identifier if none is specified.
LOG_LOCAL0 ... LOG_LOCAL7 | Reserved for local use.

The os.closelog() can be used to close the log connection.

The os.syslog() function writes message to the system message logger. The message is then forwarded to another machine if a syslog host is configured.

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 (See below). The level is selected from the following ordered (high to low) list:

LOG_EMERG | A panic condition.
LOG_ALERT | A condition that should be corrected immediately, such as a corrupted system database.
LOG_CRIT | Critical conditions, e.g., hard device errors.
LOG_ERR | Errors.
LOG_WARNING | Warning messages.
LOG_NOTICE | Conditions that are not error conditions, but should possibly be handled specially.
LOG_INFO | Informational messages.
LOG_DEBUG | Messages that contain information normally of use only when debugging a program.

## Notes

The system logging functionality was reused from OpenBSD.