I\'m using the:
console.log()
method to log messages to firefox (3.6.6)/firebug while working on my webapp. When I view the app locally, it w
i found this one which looks even better because it has all the console methods. not just log
(function(){
if (!window.console||!console.firebug){
var methods = [
"log", "debug", "info", "warn", "error", "assert",
"dir", "dirxml", "group", "groupEnd", "time", "timeEnd",
"count", "trace", "profile", "profileEnd"
];
window.console = {};
for (var i=0; i<methods.length; i++){
window.console[methods[i]] = function(){};
}
}
})();
You can no longer detect for Firebug using !console.firebug.
"The console API formerly implemented a console.firebug property. This property was removed from the API in Firebug 1.9.0 in order to prevent sites from detecting whether a user has Firebug installed."
Console API help on Firebug wiki
The console object is not defined in FF unless Firebug is open.
In Chrome it's always defined.
One way to handle it is to define it if it is not defined:
if(!window.console) console = {log: function() {}};