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

bunyan-streams-config

v1.0.2

Published

Create bunyan streams from JSON configuration

Readme

Bunyan Streams Config

This package provides a function which creates a bunyan streams configuration from a simple JSON, i.e. one which can easily be exposed in a configuration file and set by the end user without having to worry about technical details of bunyan or node.

Example

In a config file:

"log": [
  {
    "type": "console-pretty",
    "level": "debug"
  },
  {
    "type": "file",
    "path": "app.log"
  }
]

in application:

const bunyan = require('bunyan');
const bunyanStreamsConfig = require('bunyan-streams-config');
const config = // Load JSON config

const log = bunyan.createLogger({
  name: 'my-app',
  streams: bunyanStreamsConfig(config.log)
});

log.error("D'oh!");

would create two streams, one directed to the console (pretty-printed), the other to a file.

bunyan-streams-config is similar to bunyan-config, but with a few differences:

  • you can add custom stream types as a second argument to bunyanStreamsConfig

  • bunyan type of the stream is not exposed to the user (raw or other)

  • serializers are not exposed to the user

  • bunyan-streams-config provides 4 pre-defined stream types: console, console-pretty, file, file-pretty

Install

npm install bunyan-streams-config

API

bunyanStreamsConfig(streams, options)

Create bunyan streams from JSON configuration.

  • streams (Array): Array of streams, where stream is an object:

    • type: Stream type. One of pre-defined types (see below) or one in options.streamTypes.

    • other: Options passed to the stream type function.

  • options (Object): Options:

    • streamTypes (Object): Custom stream types, where key is the stream type name and value is a function which creates the stream.

    • defaults (Object): Default properties passed to stream type functions.

The function throws an error if any stream type in streams is invalid.

Pre-defined Stream Types

console

Console/stderr stream (bunyan JSON objects).

console-pretty

Console/stderr stream (pretty-printed with bunyan-prettystream).

file

File stream (bunyan JSON objects). Options:

  • path: Log file path.

file-pretty

File stream (pretty-printed with bunyan-prettystream). Options:

  • path: Log file path.

Custom Stream Types

Custom stream types can be supported by supplying a function which creates a bunyan stream.

Example:

log-file.js:

'use strict';

const _ = require('lodash');

module.exports = function createStream(options) {
  return _.defaults({
    stream: process.stderr
  }, options);
};

in application:

const log = bunyan.createLogger({
  name: 'my-app',
  streams: bunyanStreamsConfig(config.log, {
    streamTypes: {
      'file': require('log-file.js')
    }
  })
});

Some bunyan packages are suitable to be passed in streamTypes as is, e.g.:

const log = bunyan.createLogger({
  name: 'my-app',
  streams: bunyanStreamsConfig(config.log, {
    streamTypes: {
      'seq': require('bunyan-seq').createStream
    }
  })
});

for logging to Seq. The output of the function should be an object normally passed to bunyan.createLogger as an item of the streams array.

License

Bunyan Streams Config is provided under the terms of the MIT license (see LICENSE.md).