Skip to content

Instantly share code, notes, and snippets.

@mikelehen
Created April 16, 2013 19:06
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikelehen/5398652 to your computer and use it in GitHub Desktop.
Save mikelehen/5398652 to your computer and use it in GitHub Desktop.
Wraps console.log to include a timestamp (in seconds since the wrapper was initialized) with every log message.
console.log = (function() {
var console_log = console.log;
var timeStart = new Date().getTime();
return function() {
var delta = new Date().getTime() - timeStart;
var args = [];
args.push((delta / 1000).toFixed(2) + ':');
for(var i = 0; i < arguments.length; i++) {
args.push(arguments[i]);
}
console_log.apply(console, args);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment