caterpillar-human

Turn your [Caterpillar](https://github.com/bevry/caterpillar) logger stream into a beautiful readable format with colors and optional debug information

npm install caterpillar-human
97 downloads in the last day
687 downloads in the last week
3 794 downloads in the last month

Human Transform for Caterpillar

Build Status NPM version Dependency Status Development Dependency Status
Gittip donate button Flattr donate button PayPayl donate button BitCoin donate button

Turn your Caterpillar logger stream into a beautiful readable format with colors and optional debug information

Install

Node

  • Use: require('caterpillar-human')
  • Install: npm install --save caterpillar-human

Browserify

  • Use: require('caterpillar-human')
  • Install: npm install --save caterpillar-human
  • CDN URL: //wzrd.in/bundle/caterpillar-human@2.1.2

Ender

  • Use: require('caterpillar-human')
  • Install: ender add caterpillar-human

Usage

Example

// Import
var logger = require('caterpillar').createLogger();
var human = require('caterpillar-human').createHuman();

// Pipe logger output to our human interface, then our human interface output to stdout
logger.pipe(human).pipe(process.stdout);

// Log
logger.log('warn',  'this is the first log entry');
// warn:  this is the first log entry
logger.log('info', 'this is the second log entry');
// info: this is the second log entry

// Wait
setTimeout(function(){
    // Set debug mode
    logger.setConfig({level:7});

    // Log
    logger.log('warn',  'this is the first log entry');
    // warn: this is the first log entry
    //    → [2013-04-25 20:37:22.692] [/Users/balupton/Projects/caterpillar-human/example.js:20] [null._onTimeout]
    logger.log('info', 'this is the second log entry');
    // info: this is the second log entry
    //    → [2013-04-25 20:37:22.693] [/Users/balupton/Projects/caterpillar-human/example.js:22] [null._onTimeout]
},0);

Human API, extends caterpillar.Transform, which extends stream.Transform

new (require('caterpillar-human').Human)(config)
  • Methods
    • constructor(config?) create our new human instance with the config, config is optional
    • pipe(child) pipe our stream to the child, also sync our config to it
    • setConfig(config) set the configuration and emit the config event
    • getConfig() get the configuration
    • format(entry) format the caterpillar logger entry
  • Configuration

    • level number, defaults to null, when set to 7 (debug level) we will debug information with the log entries
    • color boolean, defaults to true, set to false to turn off colors
    • colors objects of the level to color mapping, defaults to:

        {
            0: 'red',
            1: 'red',
            2: 'red',
            3: 'red',
            4: 'yellow',
            5: 'yellow',
            6: 'green',
            7: 'green'
        }
      
  • Events

    • config(config) emitted once our configuration has updated

History

Discover the change history by heading on over to the HISTORY.md file.

Backers

Maintainers

These amazing people are maintaining this project:

Sponsors

No sponsors yet! Will you be the first?

Gittip donate button Flattr donate button PayPayl donate button BitCoin donate button

Contributors

These amazing people have contributed code to this project:

Become a contributor!

License

Licensed under the incredibly permissive MIT license

Copyright © 2012+ Bevry Pty Ltd us@bevry.me (http://bevry.me)
Copyright © 2011 Benjamin Lupton b@lupton.cc (http://balupton.com)

npm loves you