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

listen in on calls made to the global console object

npmnpm
Version
1.0.2
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

// console overrides are enabled by default,
var spy = require('console-spy')()

var example = function () {
  console.log('First message')

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

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

  // All console methods are
  // able to be spied upon.
  console.warn('Oh no!', 123)
}

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

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

example()

Keywords

console

FAQs

Package last updated on 18 Jan 2017

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