npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@evo/winston-syslog

v3.0.0-0

Published

A syslog transport for winston

Downloads

9

Readme

winston-syslog

A Syslog transport for winston.

Installation

Installing npm (node package manager)

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

Installing winston-syslog

  $ npm install winston 
  $ npm install winston-syslog

Motivation

tldr;?: To break the winston codebase into small modules that work together.

The winston codebase has been growing significantly with contributions and other logging transports. This is awesome. However, taking a ton of additional dependencies just to do something simple like logging to the Console and a File is overkill.

Usage

To use the Syslog transport in winston, you simply need to require it and then either add it to an existing winston logger or pass an instance to a new winston logger:

  var winston = require('winston');
  
  //
  // Requiring `winston-syslog` will expose 
  // `winston.transports.Syslog`
  //
  require('winston-syslog').Syslog;
  
  winston.add(winston.transports.Syslog, options);

In addition to the options accepted by the syslog (compliant with RFC 3164 and RFC 5424), the Riak transport also accepts the following options. It is worth noting that the riak-js debug option is set to false by default:

  • host: The host running syslogd, defaults to localhost.
  • port: The port on the host that syslog is running on, defaults to syslogd's default port.
  • protocol: The network protocol to log over (e.g. tcp4, udp4, unix, unix-connect, etc).
  • path: The path to the syslog dgram socket (i.e. /dev/log or /var/run/syslog for OS X).
  • pid: PID of the process that log messages are coming from (Default process.pid).
  • facility: Syslog facility to use (Default: local0).
  • localhost: Host to indicate that log messages are coming from (Default: localhost).
  • type: The type of the syslog protocol to use (Default: BSD, also valid: 5424).
  • app_name: The name of the application (Default: process.title).
  • eol: The end of line character to be added to the end of the message (Default: Message without modifications).

Metadata: Logged as string compiled by glossy.

By default, syslog messages are produced by glossy, but you can override that behavior by providing custom Producer instance via customProducer setting.

Log Levels

Because syslog only allows a subset of the levels available in winston, levels that do not match will be ignored. Therefore, in order to use winston-syslog effectively, you should indicate to winston that you want to use the syslog levels:

  var winston = require('winston');
  winston.setLevels(winston.config.syslog.levels);

The Syslog transport will only log to the level that are available in the syslog protocol. These are (in increasing order of severity):

  • debug
  • info
  • notice
  • warning
  • error
  • crit
  • alert
  • emerg

Syslog Configuration

You will have to configure your syslog server to accept TCP connections. This is usually done in /etc/syslog-ng.conf. Let's say you have an app called fnord, the configuration would look something like this:

  source tcp_s {
    tcp(ip(0.0.0.0) port(514) max-connections(256));
  };
  destination fnord_d {
    file("/var/log/fnord.log");
  };
  log { source(tcp_s); destination(fnord_d); };

If you have multiple apps which need to log via TCP, you can specify filters, as such:

  filter fnord_f { program("fnord"); };

Then modify the log statement to read:

  log { source(tcp_s); filter(fnord_f); destination(fnord_d); };

Now if you have another app, called bnord, create similar destination and filter configurations for it, and specify a new log statement, with the same source:

  log { source(tcp_s); filter(bnord_f); destination(bnord_d); };

For this to work, you have to make sure you set the process.title variable in your node app.

  process.title = 'fnord';

Author: Charlie Robbins

Contributors: Squeeks