Created
July 21, 2010 13:37
-
-
Save abhiomkar/484491 to your computer and use it in GitHub Desktop.
User-defined console.log() function for debug messages in JavaScript. Useful if Firebug is not installed in your browser.
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
// Author: Abhinay Omkar | |
if(!window.console){ | |
var console = { | |
log: function(msg){ | |
throw new Error(msg); | |
} | |
} | |
} | |
// Use It | |
// If Firebug is installed in your browser the logger of Firebug will be called | |
// Otherwise, the above user defined function will be called. | |
console.log("Hello World!"); |
Sweet! I've modified the code as you suggested. Thanks much!
Dude. Firebug lite.
http://getfirebug.com/firebuglite
Right-Click => Add to Bookmarks or <script src=.../firebuglite.js> if you're going to be modifying the page in question anyway.
I've just written my own log wrapper function that enclosed it in a try/catch.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
!console will break. You don't need to use new. console.log takes any number of params.