Created
March 2, 2018 09:33
-
-
Save ragingwind/a88f7cb8c9b70dff675db07a1a78fb36 to your computer and use it in GitHub Desktop.
Logger with console.log and call stack in strict mode
This file contains 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 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