strongloop / modern-syslog

modern-syslog
Other
49 stars 19 forks source link

modern syslog - streaming, async, native, uses nan

This is the only syslog library that:

Default mask depends on system.

Installation

npm install --save modern-syslog

API

For detailed descriptions of the core functions, see man 3 syslog.

Note that syslog functions cannot fail, and neither throw errors, nor callback with errors. This is consistent with the core functions, which do not have error return values.

log(priority, msg, callback)

priority can be a String, in which case it will be looked up in syslog.level. It can also be a Number, in which case it is expected to be a numeric value, such as syslog.level.LOG_INFO, optionally ORed with a a numeric facility, such as syslog.facility.LOG_LOCAL2.

See below for formatted version of log().

emerg(fmt, ...)

alert(fmt, ...)

crit(fmt, ...)

error(fmt, ...)

err(fmt, ...)

warn(fmt, ...)

warning(fmt, ...)

note(fmt, ...)

notice(fmt, ...)

info(fmt, ...)

debug(fmt, ...)

Convenience functions, log level is pre-defined, facility uses default, either system default or that provided to open(), and message is formatted with util.format().

new Stream(level, [facility])

Returns a writeable stream that logs all messages at the specified level and facility.

open(ident, option, facility)

Set up defaults for log.

Calling open() is optional, all arguments are provided with defaults, though the defaults depend on the system (see man page).

close()

Close the socket to the syslog system.

Calling close() is optional, the socket is closed automatically by the system on exit.

upto(level)

Log all levels upto and including level.

setmask(mask)

Not convenient to use but part of the low-level syslog API. See syslog man page for details, and consider using upto() for most common use-cases.

curmask()

Returns current log mask, see setmask().

setMask(...)

Avoid this, its for backwards compatibility with node-syslog.

init(...)

Avoid this, its for backwards compatibility with node-syslog.

Properties

Syslog properties are defined as a bi-directional map from String to Number, and from Number to String, so:

syslog.level

Levels are listed from highest priority, to lowest:

syslog.option

Object of properties:

These are unlikely to be useful, but are provided for completeness:

syslog.facility