Skip to content

Instantly share code, notes, and snippets.

@Kudo
Last active December 11, 2015 04:29
Show Gist options
  • Save Kudo/4545771 to your computer and use it in GitHub Desktop.
Save Kudo/4545771 to your computer and use it in GitHub Desktop.
Override default logging function with date information. (Updated from Vexed master's comments)
(function() {
var overrideFuncs = ["log", "error", "info", "warn", "trace"];
for (var i = 0, n = overrideFuncs.length; i < n; ++i) {
(function(fName) {
var fn = console[fName];
console[fName] = function() {
var time = new Date().toISOString();
var newArgs = Array.prototype.slice.call(arguments);
newArgs.unshift(time + " [" + fName.toUpperCase() + "] -");
fn.apply(this, newArgs);
}
})(overrideFuncs[i]);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment