Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

bunyan-stdout-stream

Goodluckhf35MIT1.5.4

stdout pretty print, human readable stream for bunyan

bunyan, stdout, logs, log, stream, bunyan stream, stdout logs, debug, pretty logs

readme

BunyanStdoutStream

Greenkeeper badge

Travis Coveralls github branch node npm

GitHub top language GitHub code size in bytes David David

license GitHub last commit semantic-release

During developing you usually put logs to stdout. But it's very uncomfortable to read default bunyan logs. So I've developed StdoutStream for bunyan which will prettify your logs.

Example

example

will print in your terminal: example

Install

  1. install via npm

    $ npm i bunyan-stdout-stream --save-dev
  2. instsall bunyan logger

$ npm i bunyan
  1. create logger in you project `javascript import StdoutStream from 'bunyan-stdout-stream'; import bunyan from 'bunyan';

const logger = bunyan.createLogger({ name : 'exampleLogger', streams: [{ level : 'trace', type : 'raw', stream: new StdoutStream(), }] });


## Customisation

You can customize colors and other options by putting your config, which will be deeply merge with default config:

```javascript
new StdoutStream({
    maxDepth: 7,
    colors: {
        date: date => date
    },
})

All properties of config you can find -> https://github.com/Goodluckhf/BunyanStdoutStream/blob/master/src/config.js

Also you can change any of formatter class. You have to extend it from BaseFormatter:

import BaseFormatter from 'bunyan-stdout-stream/formatters/BaseFormatter';

class CustomErrorFormatter extends BaseFormatter {
    // The only method you have to define
    format(error) {
        return error.toString();
    }
}

new StdoutStream({}, {
    ErrorFormatter: CustomErrorFormatter
});

List of formatters:

  • OptionLineFormatter - first line of log message
  • ArrayFormatter - formatter of array
  • ErrorFormatter - formatter of error
  • ObjectFormatter - formatter of object (key:val)