patch-console
Patch console methods to intercept output
Last updated 3 years ago by vdemedes .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install patch-console 
SYNC missed versions from official npm registry.

patch-console test

Patch console methods to intercept output

Install

$ npm install patch-console

Usage

import patchConsole from 'patch-console';

const restore = patchConsole((stream, data) => {
	// stream = 'stdout'
	// data = "Hello World"
});

console.log('Hello World');

// Restore original methods
restore();

API

patchConsole(callback)

After this function is called, output from console methods will be intercepted and won't show up in the actual stdout or stderr stream. To restore original console methods and stop intercepting output, call the function which patchConsole() returns.

callback

Type: Function

Function that will be called when output from one of the console methods is intercepted. First argument is name of the stream ("stdout" or "stderr"), second argument is output itself.

Console methods

This module intercepts the following methods:

  • console.assert()
  • console.count()
  • console.countReset()
  • console.debug()
  • console.dir()
  • console.dirxml()
  • console.error()
  • console.group()
  • console.groupCollapsed()
  • console.groupEnd()
  • console.info()
  • console.log()
  • console.table()
  • console.time()
  • console.timeEnd()
  • console.timeLog()
  • console.trace()
  • console.warn()

Current Tags

  • 2.0.0                                ...           latest (3 years ago)

2 Versions

  • 2.0.0                                ...           3 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Total 1
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (8)
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE