Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Logger with console.log and call stack in strict mode
const log = console.log
console.log = function logIt() {
var stack = new Error().stack,
callee = stack.split('\n')[3].slice(7),
tag = '[LOG]';
if (arguments.length > 0) {
tag = Array.prototype.slice.call(arguments, 0)[0]
}
log.call(this, tag, callee)
arguments.length > 1 && log.apply(this, arguments)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.