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 to the global `console` object

latest
npmnpm
Version
4.0.0
Version published
Maintainers
1
Created
Source

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

FAQs

Package last updated on 07 Aug 2020

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