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
; // adds mute and resume to console console; // will logconsole; // mutes logconsole; // will not logconsole; // will not logvar data = console; // resumes log and returns logged data during muteconsole; // will logconsole; // logs {stdout: ['b'], stderr: ['c']} // alter historyconsole;console;var part = console; // preserves historyconsole;console;var history = console; // reset historyconsole; // logs ['a', 'b']
Test
$ npm test
Licence
MIT