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 🙏

© 2025 – Pkg Stats / Ryan Hefner

winston-zmq

v0.2.1

Published

A 0MQ transport for winston

Downloads

57

Readme

winston

A 0mq transport for winston.

Installation

Installing npm (node package manager)

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

Installing winston-zmq

  $ npm install winston
  $ npm install winston-zmq

Purpose

This winston transport allows you to publish logs using a 0mq pub socket (so that multiple recipients can subscribe to it)

The message is sent with a variable length prefix that allows the subscribers to subscribe log message of a certain threshold and above.

Usage

  var winston = require('winston');

  //
  // Requiring `winston-zmq` will expose
  // `winston.transports.Zmq`
  //
  require('winston-zmq').Zmq;

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

The Zmq transport takes the following options. 'db' is required:

  • transport: Transport to use for 0mq. (tcp|ipc|inproc|pgm|epgm)
  • address: Address that the socket will bind to e.g. "127.0.0.1" or "10.23.45.67"
  • separator: Separator to separate the level string from the JSON default |*|
  • prefix: Prefix used to denote the log level
  • prefixMapping: Mapping between log levels and prefix string length. Used if using custom log levels. e.g. { silly: 1, verbose: 2, info: 3, warn: 4, debug: 5, error: 6 }
  • port: [required for tcp] : port to bind to when using the tcp transport
  • level: Level of messages that this transport should log.
  • silent: Boolean flag indicating whether to suppress output.
  • formatter: Optional formatter function to override the structure of the JSON data sent to the subscriber

Metadata: Logged as a native JSON object.

Examples

###Client

var util = require('util'), zmq = require('zmq');

var socket = zmq.createSocket('sub');
socket.subscribe(''); // subscribe to all
// socket.subscribe('***'); // subscribe to info and above

socket.on('message', function(bufMsg) {
    var msg = bufMsg.toString('utf8');
    try {
        var message = msg.split('|*|')[1];
        oMessage = JSON.parse(message);
        console.log(oMessage);
    } catch(err) {
        console.log(err);
    }
});

socket.connect("tcp://127.0.0.1:7890");

Log Source

var winston = require('winston');
var Zmq = require('../lib/winston-zmq.js').Zmq;
var transports = {};

// Set up the zmq transport
transports.Zmq = new Zmq({level : 'silly',port: 7890});

// Instantiate out logger.
var logger = new (winston.Logger)({transports : [transports.Zmq]});

logger.log('silly', 'Some Text', {somekey: 'some data'});
logger.log('error', 'Some Text', {somekey: 'some data'});

Message Format

The above two messages will be transmitted as:

*|*|{"timestamp":"2011-11-16T15:53:55.912Z","level":"silly","message":"Some Text","meta":{"somekey":"some data"}}
******|*|{"timestamp":"2011-11-16T15:53:55.913Z","level":"error","message":"Some Text","meta":{"somekey":"some data"}}

Author: David Henderson