Socket
Book a DemoInstallSign in
Socket

console-spy

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

console-spy

a little module for listening in on calls made to the global `console` object

npmnpm
Version
2.0.0
Version published
Weekly downloads
15
-44.44%
Maintainers
1
Weekly downloads
 
Created
Source

console-spy

a little module for listening in on calls made to the global console object

build status

** No badge to prove it, but this module is designed to work in all browsers; even IE 6 and friends! **

install

$ npm install console-spy

usage

var spy = require('console-spy')()

spy.on('log', function () {
  // expected: ["First message"]
  // expected: ["Third message"]
})

spy.on('warn', function () {
  // expected: ["On no!", 123]
})

// note: passing a truthy value to enable
// will prevent calls from being passed
// through to the _real_ console
spy.enable()
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)

FAQs

Package last updated on 15 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts