Created
May 18, 2012 08:58
-
-
Save pincheira/2724082 to your computer and use it in GitHub Desktop.
Custom override console.log to display date on every return string
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.toUTCString(); | |
return str; | |
} | |
var orig = console.log; | |
console.log = function() { | |
var msgs = []; | |
while(arguments.length) { | |
msgs.push("[" + showDate() + "]" + ': ' + [].shift.call(arguments)); | |
} | |
orig.apply(console, msgs); | |
}; |
hint= n = 10
console.log((function f(n)
{return ((n>1)? n*f(n-1):n)})(10))
which value return?
Improved:
{
var orig = console.log
console.log = function log() {
orig.apply(console, [`[${new Date().toISOString().replace("T", " ").replace(/\..+/, "")}]`, ...arguments])
}
}
mark
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example:
It will look like this on the console: