Skip to content

Instantly share code, notes, and snippets.

@ragingwind
Created March 2, 2018 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ragingwind/a88f7cb8c9b70dff675db07a1a78fb36 to your computer and use it in GitHub Desktop.
Save ragingwind/a88f7cb8c9b70dff675db07a1a78fb36 to your computer and use it in GitHub Desktop.
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