0.1.10 • Published 8 years ago

bunyan-serializer v0.1.10

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

bunyan-serializer

bunyan-serializer is a lightweight module to pretty print a bunyan stream.

Dependences: none

NPM

Install

npm i -S bunyan-serializer

Documentation

This module creates a serializer that prints a bunyan stream in a human readable format. It was created for situations where you want readable log text and you aren't running bunyan from the CLI (cannot pipe to bunyan for pretty-printing).

I may add other formats down the road if there is a need for them so I've tried to setup its API to be as future proof as possible.

How to use

import { createPrettySerializer } from 'bunyan-serializer'

/** Optional parameters shown are the defaults if any or all are omitted. */
const serializer = createPrettySerializer({ showName: false
                                          , showHostname: false
                                          , showPid: true
                                          , showTime: true
                                          , showError: true
                                          , showSilly: false
                                          })


// ... within bunyan stream

  write = (...args) => {
    try {
      // dispatch a human readable string to whatever media the stream is targeted at.
      res.send(serializer(...args))
    } catch(err) {
      this.error(err)
      return false
    }
    return true
  };

// ...

Options

createPrettySerializer takes the following options:

NameType (default)Description
showNameBoolean (false)Show the name of the logger in logs.
showHostnameBoolean (false)Show the hostname in logs.
showPidBoolean (true)Show the process id in logs.
showTimeBoolean (true)Show the time in logs.
showErrorBoolean (true)Show error details in logs.
showSillyBoolean (false)Show extra debug information (for development / debugging purposes)
0.1.10

8 years ago

0.1.9

8 years ago

0.1.8

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago