Created
September 8, 2016 20:11
-
-
Save mikeatlas/92dfd205d9a5c4755349e7c29a46fd0e to your computer and use it in GitHub Desktop.
Overrides the console.log (specifically this is for node.js) with an ISO timestamp prefix and still handles string interpolation formats.
This file contains 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 showDate(){ | |
var date = new Date(), str = date.toISOString(); | |
return str; | |
} | |
function formatArgs(args){ | |
return util.format.apply(util.format, Array.prototype.slice.call(args)); | |
} | |
var origLog = console.log; | |
console.log = function() { | |
var strDate = " [ " + showDate() + " ] "; | |
var logString = strDate + formatArgs(arguments); | |
origLog(logString); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment