Skip to content

A Console stream for bunyan that logs out your structured fields

Notifications You must be signed in to change notification settings

raybooysen/bunyan-structured-console-stream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"
        }
    ]
}

About

A Console stream for bunyan that logs out your structured fields

Resources

Stars

Watchers

Forks

Packages

No packages published