Mozilla #JetPack: Create a simple debugger

May 27, 2011
By Bogomil Shopov
3 Comments
Post Image

So I wanted to create a simple JetPack debugger that will write me some data and will dump me some objects on my …Firefox error console.

Here is the code. This simple tutorial shows :

0. How to use some of Firefox Services via Services.jsm
1. How to work with nsIConsoleService

Why I need that? Well I want to debug some of my extensions without using console/notifications or Firebug. This can be usable for getting better support for users. You can always put some debug lines on your code that will be visible for your addon user.

Anyway this is an example library and it’s not for production use :)

Bogomil Shopov

I care about privacy, ethical design, and freedom in many aspects. I spend 20+ years working as a web developer and architect, analyst, manager, and product owner/manager in different environments, several countries, and multiple software industries like Healthcare and Hospitality. I wore many hats, and I use the knowledge gathered to optimize the flow of value across complex systems.

3 Comments

  • PJ

    May 27, 2011 at 2:56 pm

    Maybe it can be called logger, instead of debugger. I like it – it can be useful if you are using online builder at AMO website.

    Thanks for writing this tutorials Bogo!!!

    Reply
  • Jeff Griffiths

    May 28, 2011 at 3:31 am

    I like the approach, console.log is very useful but not implemented on Firefox 3.x. You could easily adjust your code to just implement a workable console.log if it doesn’t exist, sort of like this:

    https://github.com/canuckistani/jetpack-console.log-injection-example

    Reply
    • Bogo

      May 30, 2011 at 2:09 pm

      Jeff Griffiths: Awesome, thanks for the fork :)

      Reply

Leave a reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.