Log to Firefox console

You can log to the Firefox console by using the method "dump" in javascript. To enable this feature in Firefox type in about:config in the address bar and create there a new boolean entry with the name "browser.dom.window.dump.enabled" and the value "true".

Now start Firefox from the command line by entering "firefox -console". All messages passed to dump() will be printed on the command line.

To automatically add a timestamp to your messages and avoid error messages in other browsers I've created this little function:

function log(message) {
if(window.dump) {
var date = new Date();
var hours = date.getHours();
if(hours < 10) hours = "0" + hours;
var minutes = date.getMinutes();
if(minutes < 10) minutes = "0" + minutes;
var seconds = date.getSeconds();
if(seconds < 10) seconds = "0" + seconds;
dump(hours + ":" + minutes + ":" + seconds + " - someapp: " + message + "\n");
}
}

1 comments:

Anonymous said...

Hi!

I have a problem with logging in ff3. I am testing an application, which is crashing ff3 all the time. If I start the console in normal or js mode, it wont help neither, because when the browser crashes, this window will close too, so I cant see there anything.

Is there a way to set ff3 to create the dump into a file?

Thanks,

A.

Post a Comment

Copyright © 2008 - J2EE on Geronimo - is proudly powered by Blogger
Smashing Magazine - Design Disease - Blog and Web - Dilectio Blogger Template