Skip to content
/ debugf Public

Slightly extended npm debug evaluating function as arguments lazily

License

Notifications You must be signed in to change notification settings

jfseb/debugf

Repository files navigation

debugf Build StatusCoverage Status

debugf

A tiny wrapper extending npm debug module, which allows to pass function as arguments which will be lazily evaluated only if debugging is enabled

Installation

$ npm install debugf

Usage

debugf, just like debug exposes a function; simply pass this function the name of your module, and it will return a decorated version of console.error for you to pass debug statements to. This will allow you to toggle the debug output for different parts of your module as well as the module as a whole.

**THe difference to debug is that if a funciton is passed as argument, this is evaluated and the result output if debugging is enabled for this module the plain debug module outputs [Function] **

Thus this is a slightly incompatible drop-in replacement for debug

var debug = require('debugf')('http')
  , process = require('process'),
  , name = 'MyApp';

//

debug('booting %s', name);

// dump environment
debug( () =>  Object.properties(process.env).map( p =>  ).join("\n") );


// dump environment
debug( function() {
    // do something really heavy but only when debugging is on
    return collectAllTheWorld()
});


// fake worker of some kind

For other features and documentation, refer to debug

About

Slightly extended npm debug evaluating function as arguments lazily

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published