Giter Site home page Giter Site logo

winston-rsyslog's Introduction

winston-rsyslog

An Rsyslog transport for winston.

Usage

  var winston = require('winston');

  //
  // Requiring `winston-rsyslog` will expose 
  // `winston.transports.Rsyslog`
  //
  require('winston-rsyslog');

  winston.add(winston.transports.Rsyslog, options);

The rsyslog transport takes the following options:

  • level: Level of messages that this transport should log
  • host: Host where rsyslog runs (default : localhost)
  • port: rsyslog port (default is 514)
  • facility: Facility index (default is 0, valid values are from 0 to 23)
  • protocol: TCP or UDP (values can be "T" or "U" accordingly, default is "U")
  • hostname: The hostname the application is running at (default is the current hostname)
  • tag: A tag to name the application for easy log filtering (default is 'winston')
  • timeout: Socket timeout for TCP (default is 2000 ms)
  • levelMapping: Mapping of level names to rsyslog security levels (defaults to winston.config.syslog.levelMapping)
  • dateProvider: A parameterless function that returns a date string (default is new Date().toISOString())
  • messageProvider: A function that returns the message string, takes three parameters: level, msg and meta (msg is already formatted by winston)

Through facility parameter, You'll be able to use the right log file on rsyslog:

0 :  kernel messages
1 :  user-level messages
2 :  mail system
3 :  system daemons
4 :  security/authorization messages
5 :  messages generated internally by syslogd
6 :  line printer subsystem
7 :  network news subsystem
8 :  UUCP subsystem
9 :  clock daemon
10 : security/authorization messages
11 : FTP daemon
12 : NTP subsystem
13 : log audit
14 : log alert
15 : clock daemon (note 2)
16 : local use 0 (local0)
17 : local use 1 (local1)
18 : local use 2 (local2)
19 : local use 3 (local3)
20 : local use 4 (local4)
21 : local use 5 (local5)
22 : local use 6 (local6)
23 : local use 7 (local7)

Enabling rsyslog

To let rsyslog receive data through UDP port, you should change its configuration (typically located in /etc/rsyslog.conf), enabling the following tags:

$ModLoad imudp
$UDPServerRun 514

The first tag enables UDP reception, while the second one defines the listening port.

To enable TCP reception on port 10514 (as an example):

$ModLoad imtcp
$InputTCPServerRun 10514

Motivation

Just for fun, while learning NodeJS. This (simple) project is based on winston-loggly (thanks @indexzero for the inspiration).

Installation

Installing npm (node package manager)

  $ curl http://npmjs.org/install.sh | sh

Installing winston-rsyslog

  $ npm install winston
  $ npm install winston-rsyslog

Run Tests

All of the winston tests are written in vows, and cover all of the use cases described above. To configure the destination rsyslog daemon parameters, copy the test/config.example.json file into test/config.json and modify it to suite your needs. If no test/config.json file is found, defaults will be used.

Then you can run tests with npm:

  $ npm test

Author: [Fabio Grande] (http://about.me/fgrande)

License: MIT

winston-rsyslog's People

Contributors

broox avatar fgrande avatar

Watchers

 avatar  avatar

Forkers

pz07

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.