Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including bunyan-syslog with all npm packages installed. Try it out:

var bunyanSyslog = require("bunyan-syslog")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

bunyan-syslog v0.1.2

Syslog Stream for Bunyan

bunyan-syslog is a stream for bunyan that consumes raw records from bunyan and sends them to a syslog server.

Installation

npm install bunyan-syslog

Usage

var bunyan = require('bunyan');
var bsyslog = require('bunyan-syslog');

var log = bunyan.createLogger({
    name: 'foo',
    streams: [ {
        level: 'debug',
        type: 'raw',
        stream: bsyslog.createSyslogStream({
            facility: bsyslog.facility.local0,
            host: '192.168.0.1',
            port: 514
        })
    } ]
});

log.debug({foo: 'bar'}, 'hello %s', 'world');

That's pretty much it. You create a syslog stream, and point it at a syslog server (UDP by default; you can force TCP by setting type: tcp in the constructor); default is to use facility user and a syslog server on 127.0.0.1:514. Note you must pass type: 'raw' to bunyan in the stream or this won't work.

Mappings

This module maps bunyan levels to syslog levels as follows:

+--------+--------+
| Bunyan | Syslog |
+--------+--------+
| fatal  | emerg  |
+--------+--------+
| error  | error  |
+--------+--------+
| warn   | warn   |
+--------+--------+
| info   | info   |
+--------+--------+
| *      | debug  |
+--------+--------+

License

MIT.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free