📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP
Socket
Sign inDemoInstall
Socket

console.mute

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

console.mute

Temporarily mute the log. Resume and retrieve logged data later. For node.js

0.3.0
latest
Source
npm
Version published
Maintainers
1
Created
Source

npm version Build Status

console.mute

Temporarily mute the console in node.js. Works with .log and .error. Resume and retrieve logged data later. Useful for intercepting logged data from any module and when testing modules that insist on logging all the things. Based on this gist. Here's a gist that works in the browser.

Install

$ npm install console.mute

Usage

require('console.mute'); // adds mute and resume to console

console.log('a'); // will log
console.mute(); // mutes log
console.log('b'); // will not log
console.error('c'); // will not log
var data = console.resume(); // resumes log and returns logged data during mute
console.log('c'); // will log
console.log(data); // logs {stdout: ['b'], stderr: ['c']}

// alter history
console.mute();
console.log('a');
var part = console.resume('preserve'); // preserves history
console.mute();
console.log('b');
var history = console.resume(); // reset history
console.log(history.stdout); // logs ['a', 'b']

Test

$ npm test

Licence

MIT

Keywords

console

FAQs

Package last updated on 10 Aug 2016

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