debugf
v0.1.2
Published
debug with lazy function argument evaluation
Downloads
30
Readme
debugf
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