Created
December 3, 2010 10:23
-
-
Save dotmaster/726802 to your computer and use it in GitHub Desktop.
hijacking Javascript console.log revamped with StackTrace (just Google Chrome)
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
// usage as usual: console.log('inside coolFunc',this,arguments); | |
if (typeof console !== "undefined") { | |
console.logJack = console.log; | |
window.log={} | |
window.log.history = window.log.history || {}; // store logs to a global history for reference | |
console.log=function(){ | |
var timestamp= (new Date); //create a timestamp of the log | |
var millis=timestamp.getTime(); | |
var readableString=timestamp.toUTCString(); | |
var stack=new Error().stack; //save a stacktrace for Google Chrome | |
var array=Array.prototype.slice.call(arguments); | |
var args={arguments:array, stackTrace:stack} | |
log.history[millis]=args; //save everything to the log | |
console.logJack(readableString, arguments, millis); //call the original log function with a timestamp | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks promising, but your'e not passing the stack trace anywhere into the orig. console log?