Skip to content

Latest commit

 

History

History
47 lines (30 loc) · 1.65 KB

README.md

File metadata and controls

47 lines (30 loc) · 1.65 KB

winston-modern-syslog

Build Status

A syslog transport for winston that is a simple wrapper for the modern-syslog library.

Installation

npm install --save winston-modern-syslog

Usage

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 test