depugger

small debugging utility

node-depugger

Depugger is a small lib that provides a debugging utility.

$ npm install depugger

depugger returns a function that supports all of the util.format features and outputs debug messages based on the initial configuration.

  • debug: specifies if logged messages should be outputted, optional, default: false
  • name: a category key that will prepend every message, optional, default: ""
  • options: options hash that can be used to submit all of the above parameters at once
var depugger = require('depugger');
 
var debug = depugger(true, 'fooDebugger');
 
debug('foo');
debug('bar "%s"', 'bax');
debug('spam %d eggs', 10);
 
//output to console: 
//[fooDebugger] foo 
//[fooDebugger] bar "bax" 
//[fooDebugger] spam 10 eggs 

Alternatively all parameters can be specified via an options hash:

var depugger = require('depugger');
 
var debug = depugger({debug: true, name: 'fooDebugger'});
 
debug('foo');
debug('bar "%s"', 'bax');
debug('spam %d eggs', 10);
 
//output to console: 
//[fooDebugger] foo 
//[fooDebugger] bar "bax" 
//[fooDebugger] spam 10 eggs 
 

Creates a child instance. The name of the parent's debugger will be concatenated with the childDebugger's name:

var depugger = require('depugger');
 
var debug = depugger({debug: true, name: 'fooDebugger'});
 
var childDebug = debug.child('child');
 
childDebug('foo');
 
//output to console: 
//[fooDebugger.child] foo