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

winston-socket.io

v1.2.0

Published

A winston transport that will emit logs to a socket.io server.

Downloads

224

Readme

winston-socket.io

Build Status

A socket.io transport for winstonjs. Gives you the ability to log directly to a socket.io server.

See the examples folder for more usage details.

Options

  • host: The hostname of the socket.io server (default: "").
  • port: The port of the socket.io server (default: 3000).
  • url: The url you wish to connect to (will override host and port options) (default: "").
  • secure: Use https for the socket.io server connection (will be overriden by url option) (default: false).
  • namespace: The socket.io namespace to use for the logs (default: "log").
  • log_topic: The topic to send the log messages on (default: "log").
  • log_format: The format in which to log the information.
  • batch: whether or not to batch log messages and send them out in groups instead of immediately when logging (default: false)
  • batch_interval: amount of time in ms to wait after logging to flush log queue and send over the socket (default: 1000)
  • batch_count: maximum number of log messages to queue before sending over the socket (default: 10)
  • max_buffer: The maximum number of messages to queue up for publishing if the client isnt connected to the server or if batching (default: 1000).
  • socket_options: Any options you wish to give to the socket client (default: nothing).

How to use it

  const winston = require('winston');
  require('winston-socket.io');

  let logger = winston.createLogger({
    level: "info",
    transports: [
      new winston.transports.Console(),
      new winston.transports.SocketIO(
        {
          host: "myhost",
          port: 8080
          secure: true,
          namespace: "log",
          log_topic: "log"
        }
      )
    ]
  });  

  logger.log("info", "I'm logging to the socket.io server!!!");
  logger.log("info", "I'm logging something else", {meta: "some additional info"});

Can also be added to Winston as a transport in this method


  const winston = require('winston');
  require('winston-socket.io');

  winston.add(new winston.transports.SocketIO({
    host: "myhost",
    port: 8080
    secure: true,
    namespace: "log",
    log_topic: "log"
  }));

Browser Demo

In the example folder is a demo of winston being used on the client side with both the browser console extension and winston socket.io logging back to the webserver.

If you want to try it out (Assuming you have nodejs installed):

  git clone https://github/jbass86/winston-socket.io
  cd winston-socket.io
  npm install
  npx gulp build-demo
  node examples/demo/app.js

Then open your browser up and navigate to "localhost:8080"