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

v1.2.2

Published

A wrapper to make winston use simpler

Readme

winston-wrap

This library is a simple wrapper around winston logger initialisation. Default config returns a logger with 2 transports (file and console) pre-configured.

Setup

npm install winston-wrap

Usage

winston-wrap exposes a single function; simply pass to this function a label name, and, why not, some options (as shown bellow) and it will return a winston logger object ready to be used.

Default Usage

With no parameters passed to the require, 2 transports are created with the following pre-configured caracteristics :

console :

config.file = {
	level: 'debug',
	filename: `./output-${appName}.log`,
	handleExceptions: true,
	maxsize: 5242880, // 5MB
	maxFiles: 5,
	format: format,
};

file :

config.console = {
	handleExceptions: true,
	format: combine(
		logformat.colorize(),
		format,
	),
};

colors :

config.colors = {
	error: 'red',
	warn: 'magenta',
	info: 'green',
	verbose: 'yellow',
	debug: 'cyan',
	silly: 'white',
};

finally, the logger :

config.logger = {
	level: 'debug',
	exitOnError: false, // do not exit on handled exceptions
	transports: [
		new transports.File(config.file),
		new transports.Console(config.console),
	],
};

In short, logs are sent to a file (filename: ./output-${appName}.log,) and simultaneously to the console (with some colorization for the latter).

Example with all defaults :

const logger = require('winston-wrap');
const options = { file: null, console: { level: 'verbose' } }

logger.debug('options %o', options);

will output the following text in console and in ./output.log :

2019-01-02 14:40:30 [debug]: options { file: null, console: { level: 'verbose' } }

Usage with a label

If you pass a string to the require creating the logger, you will add a label to each log line. This label can be used to identify the module which generated the line :

Logs are still sent to a file (filename: ./output-${appName}.log,) and to the console.

Example :

const logger = require('winston-wrap')('index.js');
const options = { file: null, console: { level: 'verbose' } }

logger.debug('options %o', options);

will output the following text in console and in ./output.log :

2019-01-02 14:40:30 [debug]: index.js - options { file: null, console: { level: 'verbose' } }

Usage with winston options

You can also pass an option object when calling the require. This object accepts the following attributes :

options = {
	file: {},
	console: {},
	colors: {},
	logger:{},
}

These attributes will simply be merged with the default config (described above) to allow you to overide it if needed. If you want to deactivate a transport, just affect a null attribute.

The configuration of each sub-object has to follow winston rules as shown in their documentation. file is a transport.File configuration object, console a transport.Console one, etc...

Example 1 :

const options = { file: null, console: { level: 'verbose' } }
const logger = require('winston-wrap')('index.js', options);

logger.debug('options %o', options);

will output nothing, ...anywhere. (file output is disabled and console output is elevated to verbose)

Example 2 :

const options = { file: null, console: { level: 'verbose' } }
const logger = require('winston-wrap')('index.js', options);

logger.warn('options %o', options);

will output the following to the console (and no file) :

2019-01-02 14:40:30 [warn]: index.js - options { file: null, console: { level: 'verbose' } }

Example 3 :

const app = 'myApp';
const options = { file: { filename: `/home/pi/output-${app}.log` } }
const logger = require('winston-wrap')('index.js', options);

logger.info('options %o', options);

will output anything to the console and the following to an app dedicated output log in your /home/pi directory :

2019-01-02 14:40:30 [info]: index.js - options { file: { filename: '/home/pi/output-myApp.log' } }