Created
June 10, 2018 09:35
-
-
Save octaharon/79564c0389c01a863ca47bfc6f91fcab to your computer and use it in GitHub Desktop.
Intercept/override/disable console calls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const consoleOverride = { | |
'log': options.debug && options.verbose, | |
'debug': options.debug, | |
'info': options.verbose | |
} | |
Object.keys(consoleOverride).forEach(cmd => { | |
let oldMethod = console[cmd].bind(console); | |
console[cmd] = function (...args) { | |
if (consoleOverride[cmd]) | |
return oldMethod.apply( | |
console, | |
args | |
); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment