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 🙏

© 2025 – Pkg Stats / Ryan Hefner

sb-logger

v1.5.0

Published

Factory for winston loggers

Downloads

6

Readme

sb-logger

Wrapper for creating winston loggers.

The loggers created build on Winston by providing defaults that can be overridden, as well as new functionality such as the ability to mask messages.

Supports the same log levels as the window console (error, warn, info, debug), with the default set to info.

Creating loggers

var logger = require('sb-logger');
var log;

// default un-named logger: uses console as default transport with 'sb_rest_1' as the format
log = logger.getLogger();

// default un-named logger: uses console as default transport with 'sb_rest_2' as the format
log = logger.getLogger('sb_rest_2');

// default logger named 'wibble': uses console as default transport with 'sb_rest_1' as the format
log = logger.getLogger('sb_rest_1', 'wibble');

// logger configured using config object
log = logger.getLogger(config);

Transports

Transports default to a console transport with the specified formatter, or the default if no formatter is specified. The transports can be overridden by using the config.transports property of a config object

logger.getLogger({
  transports: [...]
});

Formats

The loggers support named logging formatters. The formatter is specified at creation time and defaults to 'sb_rest_1' if not specified.

The formater can be specified as the first string argument to getLogger() or as the config.format property of a config object, or set directly on any transport supplied in the config object config.transports.

The logger can be used to access the formatters by name, logger.getFormatter(name), returning returning the default if the format is not known.

The logger creates a log object as follows:

{
  name: '...',
  timestamp: '...',
  context: {..}, // config.ctxt
  message: '...'
}

Formatters get passed an args object which has a meta property representing the log object;

Masks

Masks apply a pattern to the message and replace any matches with a mask to hide sensitive data. Masks are applied in the order specified.

Masks always include a mask for jwt tokens and is applied first.

{ pattern: /([a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?)/gm, mask: '****' }

Custom masks can be specified using the config object:

{
  masks: [
    { pattern: /foo/, mask: 'bar' }
  ]
}

Message size

By default, the message is split into 1000 character chunks and each chunk logged separately. Each chunk is logged with the same timestamp. The maximum number of characters can be specified on the config object.

{
  splitChars: 500 // default 1000
}

Config Object

{
  name,
  format,
  transports,
  masks,
  ctxt,
  splitChars
}