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 🙏

© 2026 – Pkg Stats / Ryan Hefner

winston-primus

v1.0.0

Published

A generic websocket transport for winston based on primus

Downloads

33

Readme

winston-primus

This is a generic websocket Transport for winston based on primus. Thanks to Primus you can change your websocket library without changes your application.

Installation

Install winston-primus as usual:

$ npm install winston-primus

Options

When you add winston-primus to your winston logger, you can provide this options:

  • level: (Default: 'debug') Required log level
  • host: (Default: 127.0.0.1) Remote host of the websocket logging endpoint
  • port: (Default: 4000) Remote port of the websocket logging endpoint
  • timestamp: (Default: false) Boolean flag indicating if we should add a timestamp to the output. If function is specified, its return value will be used instead of timestamps.
  • transformer: (Default: 'websocket') The transformer used by Primus
  • pathname: (Default: '/winston') The URL namespace that Primus can own
  • parser: (Default: 'json') Message encoder for all communication

Usage

To use this plugin you must have a websocket logging endpoint (server) and at least a logger (client).

Server

Create your own server use this simple example:

// dependencies
var http      = require('http')
  , Primus    = require('primus')
  , winston   = require('winston');

// create the server
var server = http.createServer(function (req, res) {
  res.end();  // empty response
});

// create a customized Console Transport
var consoleTransport = new winston.transports.Console({
  level: 'debug',
  colorize: true,
  timestamp: false
});

// create new Logger
var logger = new (winston.Logger)({
  transports: [
    consoleTransport // add other Transport types if you need
  ],
  exitOnError: true
});

// wait for incoming logs
var primus = new Primus(server, {
  transformer: 'websockets',
  pathname: '/winston'
});

primus.on('connection', function connection(spark) {
  logger.info('new connection from %s:%s', spark.address.ip, spark.address.port);

  spark.on('data', function data(packet) {
    logger.log(packet.level, packet);
  });
});

server.listen(4000, '127.0.0.1');

logger.info('server started');

Save as server.js and start the server:

$ node server.js

info: server started

Client

Into the client simply add winston-primus as new Transport to your winston instance:

var winston = require('winston');
var Primus = require('winston-primus').Primus;
winston.add(Primus, { level: 'debug', timestamp: new Date() });
winston.info('Debug text only message');
winston.info('Debug exented message', { custom: 'Test Object Log Message', error: false });
winston.log('info', 'Test Log Message', { anything: 'This is metadata' });

Save as client.js and start it:

$ node client.js

info: Test Log Message anything=This is metadata

Now in your previous terminal session (that when the server is running) you see this new lines:

info: new connection from 127.0.0.1:50025
debug:  level=debug, message=Debug text only message, timestamp=2014-03-16T07:23:47.009Z
debug:  custom=Test Object Log Message, error=false, level=debug, message=Debug exented message, timestamp=2014-03-16T07:23:47.010Z
info:  anything=This is metadata, level=info, message=Test Log Message, timestamp=2014-03-16T07:23:47.011Z

Note that into the client terminal you see only the info message whereas into the server terminal you see all messages because the server has a customized level of the Console Transport.

For more information please refer to winston and primus documentations.

Run Tests

Like other Transport plugins, all of the winston-primus tests are written in vows, and designed to be run with npm.

$ npm test