Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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