sconsole v0.0.5
node-sconsole
Unified logger to console and syslog.
npm install sconsole
How to use
var sconsole = require('sconsole');
sconsole.setup({
upto: sconsole.priority.info,
ident: 'my app',
stdio: true,
syslog: {
upto: sconsole.priority.error // overrides value in parent object
}
});
sconsole.error('error message');
sconsole.warn('warning message');
sconsole.info('info message');API
setup(options)
Options:
uptoNumber default=sconsole.priority.debug- log messages up to this priority.stdioBoolean|Object - console output configuration.syslogBoolean|Object - syslog output configuration.
stdio and syslog object values can be defined in top priority options object. See example above.
stdio options:
true- write to console using default options.false- do not write to console.Object- overrides parent options object. Specific options:outStream - stdout stream for messages with priority >=4.errStream - stderr stream for messages with priority <4.formatFunction - message format function.
syslog options:
true- write to syslog using default options.false- do not write to syslog.Object- overrides parent options object. Specific options:uptoNumber default=sconsole.priority.debug- overrides top level option.identString default=process.title - message prefix used in syslog.facilityNumber default=sconsole.facility.user- program type.formatFunction - message format function.
Format function arguments:
dataObject - message data.optionsObject - options object.
Format function is expected to return string.
Constants
sconsole.priority- log priority constants, see constants.js.sconsole.facility- syslog facilities, see constants.js.
Priority and console methods
sconsole is replacement for regular console module. It extends all console's methods so they work as expected, e.g. sconsole.dir(obj, { colors: true }) will print colored object on iojs. On top of that sconsole has methods which represent syslogs' priorities, e.g. sconsole.notice(). The methods that are present in console and syslog has console's behavior and syslogs's priority. All the rest console's methods have console.log() behavior and sconsole.priority.debug priority.
Example:
sconsole.dir()-console.dir()behavior, debug priority.sconsole.error()-console.error()behavior, error priority.sconsole.notice()-console.log()behavior, notice priority.
License
ISC