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-formatted

v1.1.1

Published

A wrapper around the awesome winston logger

Downloads

6

Readme

winston-formatted

Wrapper around the the fantastic winston logging library which adds formatting and colorization, and filename of the file calling the logger method.

This library adds a helper method loggerFor() to the winston object, which creates and returns a Console transport with formatting:

const log = winston.loggerFor(module);

Motivation

Having used winston in many projects myself, I found that I wanted a nice console output and a bit more information, so I've spent some time to write a wrapper around winston to do just that.

Installation

npm install --save winston-formatted

Usage

The intention is that you can use winston as you normally would, with a formatted console output.

ES6 modules usage

import winston from 'winston-formatted';

// passing in module here allows the library to get the calling filename
const log = winston.loggerFor(module);

// using normal methods for logging
log.error('Test error');
log.warn('Test warning');
log.info('Test info');
log.verbose('Test verbose');
log.debug('Test debug');
log.silly('Test silly');

Logging levels

Logging levels in winston conform to the severity ordering specified by [RFC5424]: severity of all levels is assumed to be numerically ascending from most important to least important.

const levels = { 
  error: 0, 
  warn: 1, 
  info: 2, 
  verbose: 3, 
  debug: 4, 
  silly: 5 
};

Advanced usage

The whole winston library is passed through, and the logger returned is a normal winston Console transport.

Therefore, you can do all the things you normally would with winston. For instance, to add a File transport to your logger, with only 'error' level, do the following:

import winston from 'winston-formatted';

const log = winston.loggerFor(module);

// add more transports as required
log.add(new winston.transports.File({ filename: 'error.log', level: 'warn' }));

For full configuration options, please refer to winston

Credits

Author: Kev Marchant

Of course, all props go to the original authors of this great library.