console-spy

4.0.0 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i console-spy

Weekly Downloads

9

Version

4.0.0

License

CC0-1.0

Unpacked Size

2.67 kB

Total Files

6

Last publish

Collaborators

  • michaelrhodes