title: Registering a console service listener in a Firefox addon
body: <p>I'm having some trouble registering an nsIConsoleListener in my firefox addon. Here is my code:</p>
  
  <pre><code>var conSer  = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);
  
  var consoleLis = {
      observe:function( aMessage ){
  
          conSer.unregisterListener(consoleLis); 
  
          Components.utils.reportError("observed "+aMessage.message);
  
      },
      QueryInterface: function (iid) {
  
          if (!iid.equals(Components.interfaces.nsIConsoleListener) &amp;&amp; !iid.equals(Components.interfaces.nsISupports)) {
  
                  Components.utils.reportError("NS_ERROR_NO_INTERFACE");
  
                  throw Components.results.NS_ERROR_NO_INTERFACE;
  
          }
  
          return this;
  
      }
  };
  
  
  conSer.registerListener(consoleLis); 
  
  conSer.logStringMessage('this is a test');
  </code></pre>
  
  <p>It seems that no matter what variation of the code I try above, the QueryInterface always seems to throw an error. I had a look through bugzilla to see if there were any outstanding bugs with nsIConsoleListener, but there doesn't seem to be, so I have no idea why this isn't working.</p>