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.
- install via npm
$ npm i bunyan-stdout-stream --save-dev- instsall bunyan logger
$ npm i bunyan- create logger in you project
import StdoutStream from 'bunyan-stdout-stream';
import bunyan from 'bunyan';
const logger = bunyan.createLogger({
name : 'exampleLogger',
streams: [{
level : 'trace',
type : 'raw',
stream: new StdoutStream(),
}]
});You can customize colors and other options by putting your config, which will be deeply merge with default config:
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 messageArrayFormatter- formatter of arrayErrorFormatter- formatter of errorObjectFormatter- formatter of object (key:val)

