Skip to content

michaelrhodes/console-spy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

console-spy

listen in on calls to the global console object

ci

install

npm install https://pkg.mkr.sx/console-spy/4.0.0.tgz

use

var cs = require('console-spy')

var spy = cs(function () {
  // Mixin custom handlers
  this.warn = warn
  this.log = log

  // Withhold arguments
  // from the real console
  this.withholding = true
})

console.log('First message')

// spy can be disabled
spy.disable()
console.log('Second message')

// and re-enabled
spy.enable()
console.log('Third message')

// and all the console methods
// can be spied upon
console.warn('Oh no!', 123)

function log () {
  => ["First message"]
  => ["Third message"]
}

function warn () {
  => ["On no!", 123]
}

obey

CC0-1.0

About

listen in on calls to the global console object (370 B)

Resources

Stars

Watchers

Forks