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

good-winston

v4.0.0

Published

hapi good-reporter to winston logging adapter

Downloads

6,967

Readme

good-winston

A hapi good stream to winston logging adapter.

This stream clones good-console but terminates logs to winston.

Installation

  $ npm install -S winston
  $ npm install -S good-winston

Usage

To use the GoodWinston you simply need to require it and pass it a winston logger instance -

const GoodWinston = require('good-winston');
const winston = require('winston');
const goodWinstonStream = new GoodWinston({ winston });

The following config options are availble to configure GoodWinston:

  • config - required configuration object with the following keys
    • winston - winston logger (required).
    • level - Log level for internal events -
      • error - Map all good error events to this winston level (Default error).
      • other - Map all other good events to this winston level (Default info).
      • ops - Map all good ops events to this winston level (Default info).
      • response - Map all good response events to this winston level (Default info).
      • request - Map all good request events to this winston level (Default undefined so level will be deduced from tags).
    • format - MomentJS format string. Defaults to 'YYMMDD/HHmmss.SSS'.
    • utc - boolean controlling Moment using utc mode or not. Defaults to true.
    • color - a boolean specifying whether to output in color. Defaults to true.

Integrating with good

As with any good stream new good-winston you can either pass the created stream to good -

const GoodWinston = require('good-winston');
const goodWinstonStream = new GoodWinston({ winston: require('winston') });
const good = require('good');


server.register({
  register: good,  
  options: {
    reporters:{
      winston: [ goodWinstonStream ]
    }
}, err => {
  if (err) {
    throw err;
  }
});

Or you can have good initiate the stream from the module for you -

const winston = require('winston');
const good = require('good');

server.register({
  register: good,  
  options: {
    reporters:{
      winston: [{
        module: 'good-winston',
        args: [{ winston }]
      }]
    }
}, err => {
  if (err) {
    throw err;
  }
});

Using Tags and Levels

Using the level parameter in the config variable you can set the log level for internal events that are not controlled from your code (like ops and response) but for logs where are called from your code you should set a tag with the appropriate log level .good-winston will iterate the tag and will set the level by the first tag that matches the winston logger available levels. If no appropriate level was found other level will be used