Home  |  Blog Help Out  |  How-To Guides  |  Why Use Mozilla  |  About Jeremy

Extensions

Contact
Jeremy Gillick

Get Firefox!

DebugLogger 0.1

What is this?

This is a developer extension for firefox & thunderbird that provides a better alternative to using the dump statment. It breaks up debug statements to be unique per extension or project and let's you view them independantly in a clean colsole

How do I use it?

Start by putting debug statments within your extension using this API, like below:

1: logMngr = Components.classes["@mozmonkey.com/debuglogger/manager;1"] .getService(Components.interfaces.nsIDebugLoggerManager); 2: logger = logMngr.registerLogger("myapp"); 3: logger.log(3, "Hello World");

Now fire up your Firefox or Thunderbird, click Tools > Debug Logger and trip this debug statment in your extension. You should see 'Hello World' pop up in the console.

Code Breakdown


Line 1  Get the DebugLogger service

Line 2  Register your app with the logger (a logger object is returned). The name you provide should be unique and specific to your app.

Line 3  Send the debug message "Hello World" at a debug level of 3. The debug level is very important, it helps you mask certain debug statments from the consol; where 1 is most generic and 5 is the most specific. In the console you can choose what level of debug statments to watch by selecting the level from the drop-down menu.

Using the console

Click Tools > Debug Logger to open the colsole.


Special Hints and Tips

In order to prevent errors when somebody runs your extension without the debug logger installed, you should construct a custom wrapper function that will envoke the logger. This way it can be turned off from a single source between development and production.

When a user reports a problem with your extension, you can have them install the DebugLogger so they can provide you with important debugging data to save you lot's of time.

Install
Install For:


Version History
v 0.1
05/05/2005
  • Launched


Copyright © 2004 Jeremy Gillick, All rights reserved
All the content and code presented on this site is owned solely by Jeremy Gillick