Table of Contents
Syslog
This documents the Hop.js builtin syslog api.
Use require("hop:syslog")
to use it, or ` from "hop:syslog"`;* import
Additional information regarding syslog
can be obtained in the Unix
man page.
Functions
syslog.open(name, option, facility)
Initialize the syslog connection. The option
argument is a bit-or combination
of the following values:
syslog.LOG_CONS
: direct console writingsyslog.LOG_NDELAY
: open connection immediatelysyslog.LOG_NOWAIT
: don't wait for child processessyslog.LOG_ODELAY
: delayed opening connection until first messagesyslog.LOG_PID
: include PID with each message
The value facility must be one of:
syslog.LOG_AUTH
: security/authorization messages.syslog.LOG_AUTHPRIV
: security/authorization messages (private).syslog.LOG_CRON
: cron messages.syslog.LOG_DAEMON
: daemon messages.syslog.LOG_FTP
: ftp messages.syslog.LOG_KERN
: kernel messages.syslog.LOG_LOCAL0
: kernel messages.- ...
syslog.LOG_LOCAL7
: local messagessyslog.LOG_LPR
: printing messagessyslog.LOG_MAIL
: mail messagessyslog.LOG_NEWS
: news messagessyslog.LOG_SYSLOG
: syslog messagessyslog.LOG_USER
: generic user-level messagessyslog.LOG_UUCP
: uucp messages
syslog.log(level, msg)
Emit a log message. The argument msg
is a string. The argument level
denotes the importance of the message. The levels are, in order of decreasing
importance:
syslog.LOG_EMARG
: system is unusablesyslog.LOG_ALERT
: action must be taken immediatelysyslog.LOG_CRIT
: critical conditionssyslog.LOG_ERR
: error conditionssyslog.LOG_WARNING
: warning conditionssyslog.LOG_NOTICE
: normal but significant conditionsyslog.LOG_INFO
: informational messagesyslog.LOG_DEBUG
: debug-level message
syslog.close()
Closes the syslog
connection.
Example
This example shows how to open a SYSLOG connection and how to emit messages.
syslog/syslog.js
var Syslog = require( hop.syslog );
Syslog.open( "hopjs-syslog", Syslog.LOG_PID | Syslog.LOG_ODELAY, Syslog.LOG_LOCAL0 );
Syslog.log( Syslog.LOG_INFO, "A hop.js message [v" + process.versions.hop + "]" ) ;
Syslog.close();
console.log( "check your log file (typically /var/log/syslog)" );