di-debug

0.0.5 • Public • Published

di-debug

Colorful debug utility

Installation

$ npm install di-debug

Usage

var diDebug = require('./di-debug')
	, c = diDebug('hello') // c is short for console

// these will output 'hello world' in color
c('world')
c.log('world')
c.ok('world')
c.err('world')
c.info('world')
c.show('world')
c.time()

var worker = diDebug('worker')
worker('hi') // this will output a different color from 'hello'

Output:

output

The time method will show you the distance between the last time method has been called or when the debugger was created

var wait = diDebug('wait')
setTimeout(function(){
	wait.time() // this will output 100ms
}, 100)

The touch method will reset the time of the last time method was called

var wait = diDebug('wait')
setTimeout(function(){
	wait.touch()
	wait.time() // this will output 0ms
}, 100)

The addFilter and removeFilter will make you able to filter the output

var first = diDebug("first")
  ,	second = diDebug("second")
  ,	third = diDebug("third")


diDebug.addfilter('second') // this will make only second to give the output

diDebug.addfilter(['first', 'third']) // this will make only first, second and third to give the output

diDebug.removeFilter(['first', 'third']) // this will make only second to give the output

diDebug.removeFilter('second') // this will remove the last filter, back to normal

diDebug.removeFilter(true) // to remove all filter, back to normal

The exclude and include will make you able to exclude and include the output

var first = diDebug("first")
  ,	second = diDebug("second")
  ,	third = diDebug("third")

function callAll(){
	first('hi')
	second('hi')
	third('hi')
}

// this is the same with the top example
diDebug.exclude('second') // this will make second to not give any output

diDebug.include('second') // this will make second to go back giving output

diDebug.exclude(['first', 'third']) // this will exclude the first and the third

diDebug.include(['first', 'third']) // this will make second to go back giving output

diDebug.include(true) // this will include everyone

Provided by berdu.id

Readme

Keywords

Package Sidebar

Install

npm i di-debug

Weekly Downloads

6

Version

0.0.5

License

MIT

Last publish

Collaborators

  • arypurnomoz