bunyan-structured-console-stream

v1.0.2
A console stream that logs structured fields to the console

Intro

If you're using bunyan, there is a good chance you're passing in fields that you'll either log to some other store like seq,elk or something like that. However, it's also useful to see this in the console. This stream is built when expecting to use tokens when logging, see Usage for more details

Usage

Common log lines may look like this with bunyan.

const user = {username: 'Ray', age: 36 };
logger.debug({...user}, 'User {username}, is {age} years old');

Normally with back-end logging stores like Seq, the interpolation in this token format will occur on the server and not the client side. To enable us to have the interpoloation on the client, use this stream in your bunyan configuration.

Usage with Bunyan

import { createConsoleStream } from 'bunyan-structured-console-stream';

const options = {
    name: 'LoggerName',
    streams: [
        {
            type: 'raw', 
            stream: createConsoleStream(true),
            level: "debug"
        }
    ]
}

Metadata

  • MIT
  • Whatever
  • Ray Booysen
  • released 5/14/2019

Downloads

Maintainers