console-spy
v4.0.0
Published
listen in on calls to the global `console` object
Downloads
34
Readme
console-spy
listen in on calls to the global console
object
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]
}