kenny-loggins

Highway to the logging zone

npm install kenny-loggins
1 downloads in the last week
7 downloads in the last month

Kenny Loggins

Yet another logging library

Whirlwind Tour (will get better later I promise)

var loggins = require('kenny-loggins');

loggins.info('oh hey'); // totally cool!

The default loggins is already piped to stdout, but if you want a clean one go for it:

var kenny = loggins();

loggins.pipe(fs.createWriteStream('./log.log'));

It takes an optional arguments hash with values:

  • opts.levels: Either a list of levels, or key-value pairs of the form <level>: <color>.

This returns a stream which outputs pretty-printed logging events.

logger will have a method for every level. For example:

logger.info('this is some info');

logger.info is also a readable/writable stream. As a writable stream, it will log each chunk as a logging message. As a readable stream, it just emits the log messages.

logger.raw is the same as 'logger' except the chunks are in JSON format.

logger._pretty is used to format an object with the keys "level" and "message". You can punch this to customize what prettiness looks like. By default colorizes the message if logger.colors[level] is defined, using some copypasta from the colors library to avoid punching the prototype (looking for a better solution!!!).

Other Things

TODO:

  1. Way way way better docs
  2. Special cases for formatting errors?
  3. Unpipe?

License:

MIT

npm loves you