caterpillar-human

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

Human Transform for Caterpillar


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

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
// 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

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

These amazing people are maintaining this project:

  • Benjamin Lupton b@lupton.cc (https://github.com/balupton)

No sponsors yet! Will you be the first?

These amazing people have contributed code to this project:

Become a contributor!

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)