-
-
Save sarangkartikey50/9257f6150fbc0d1cd5d6a838c2edf55f to your computer and use it in GitHub Desktop.
Custom console which stores all the logs, errors
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
console.stdlog = console.log.bind(console); | |
console.logs = []; | |
console.log = function(){ | |
console.logs.push(Array.from(arguments)); | |
console.stdlog.apply(console, arguments); | |
} | |
console.stderror = console.error.bind(console); | |
console.errors = []; | |
console.error = function(){ | |
console.errors.push(Array.from(arguments)); | |
console.stderror.apply(console, arguments); | |
} | |
console.getLog = (logs) => { | |
logs.forEach(log => { | |
if(Array.isArray(log)) | |
console.getLog(log); | |
else | |
console.log('New log', JSON.stringify(log, null, '\t')); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment