Created
April 24, 2014 17:34
-
-
Save jcready/11262864 to your computer and use it in GitHub Desktop.
Timestamps for console.log()
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
(function(){ | |
var log = console.log; | |
console.log = function(){ | |
var timestamp = '['+new Date().toJSON().slice(14,-1)+']'; | |
if (arguments.length) { | |
if (typeof arguments[0] === "string") { | |
var args = Array.prototype.slice.call(arguments, 0); | |
args[0] = "%s " + arguments[0]; | |
args.splice(1, 0, timestamp); | |
return log.apply(console, args); | |
} else { | |
arr.unshift.call(arguments, timestamp); | |
return log.apply(console, arguments); | |
} | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment