Skip to content

Instantly share code, notes, and snippets.

@sarangkartikey50
Last active April 6, 2019 15:46
Show Gist options
  • Save sarangkartikey50/9257f6150fbc0d1cd5d6a838c2edf55f to your computer and use it in GitHub Desktop.
Save sarangkartikey50/9257f6150fbc0d1cd5d6a838c2edf55f to your computer and use it in GitHub Desktop.
Custom console which stores all the logs, errors
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