Skip to content

Instantly share code, notes, and snippets.

@jcready
Created April 24, 2014 17:34
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 jcready/11262864 to your computer and use it in GitHub Desktop.
Save jcready/11262864 to your computer and use it in GitHub Desktop.
Timestamps for console.log()
(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