3.0.0 • Published 5 years ago
winston-modern-syslog-with-circular-reference-protection v3.0.0
winston-modern-syslog
A syslog transport for winston that is a simple wrapper for the modern-syslog library.
Installation
npm install --save winston-modern-syslogUsage
To use the ModernSyslog transport in winston, simply require the module and then attach it to the winston logger, or a logger of your own creation:
var winston = require('winston');
// Requiring the module will return `winston.transports.ModernSyslog`
require('winston-modern-syslog');
// Tell winston that you're using the syslog levels instead of the defaults
winston.setLevels(winston.config.syslog.levels);
winston.add(winston.transports.ModernSyslog, {level: 'alert'});The ModernSyslog transport has the following options:
- level: Level of messages that this transport should log (default 'info').
- label: The message prefix (default
process.title). - logPid: Whether to log the application's PID with the log messages (default false).
- facility: syslog facility (default
syslog.facility.LOG_USER). - prefixLevel: Whether to prefix the log level on the log messages (default false).
As syslog only supports a subset of the levels available in winston, in the example above we explicitly configure winston to use the syslog levels.
Metadata objects are logged via JSON.stringify(meta).
Tests
The tests are written in Mocha. They can be run with npm:
npm test3.0.0
5 years ago