FBTrace

From FirebugWiki

(Difference between revisions)
Jump to: navigation, search
Line 35: Line 35:
<code>extensions.chromebug.alwaysOpenTraceConsole</code>
<code>extensions.chromebug.alwaysOpenTraceConsole</code>
 +
 +
== Tracing from your own extension ==
 +
You can use the console also from your own extension - Firebug doesn't need to be even installed. All you need is the FBTrace extension.
 +
 +
* Your extension should create a new preference:
 +
 +
<pre>
 +
pref("extensions.firebug.DBG_MYEXT", false);
 +
</pre>
 +
 +
* <code>extensions.firebug.DBG_</code> prefix is mandatory.
 +
 +
* As soon as the preference exists you should see a new option <code>MYEXT</code> in the Tracing Console.
 +
 +
* Get the tracing service in your code.
 +
<pre>
 +
Components.utils.import("resource://firebug/firebug-trace-service.js");
 +
var FBTrace = traceConsoleService.getTracer("extensions.firebug");
 +
</pre>
 +
 +
... and create a log:
 +
 +
<pre>
 +
if (FBTrace.DBG_YOUREXT)
 +
    FBTrace.sysout(string, object);
 +
</pre>

Revision as of 14:27, 11 April 2011

FBTrace

The Firebug Tracing Console (short FBTrace) is used for debugging Firebug and Firebug extensions. It logs all Firebug activities and thereby helps tracking down errors inside the source code.

Contents

Installation

Until Firebug 1.7 FBTrace was bundled together with its alpha and beta versions. To be able to inspect the logs even in the case Firebug is broken (e. g. it doesn't even load itself) and to make the release process easier for Firebug 1.8 FBTrace was extracted from the Firebug source and is now available as an independent extension. For more information about this step please read the news group thread about FBTrace as well as the blog entry to Firebug 1.8a1.

From XPI

The simplest way how to install FBTrace extension is to use an XPI we regularly build from the source. Check releases directory for the latest version.

From Source

You can get the FBTrace source using a Subversion client. To install FBTrace please follow the description of building Firebug from source or place a file named fbtrace@getfirebug.com containing the path to the source code in your Firefox profile directory (for more info on how to do this please read the steps to create a Firefox extension proxy file).

How to open the console

After you installed FBTrace you have following possibilities to start it:

Firebug

Firebug allows opening of the console from Firebug Icon Menu

  • Firebug Icon Menu -> Open Tracing
  • Firebug Icon Menu -> Options -> Always Open Tracing

Trace-console.png

If you want to open the console for Firebug automatically after restart you need to set following preference to true:

extensions.firebug.alwaysOpenTraceConsole

Chromebug

  • Chromebug Tools -> Open Chromebug Tracing Console

Trace-console-chromebug.png

If you want to open the console for Chromebug automatically after restart you need to set following preference to true:

extensions.chromebug.alwaysOpenTraceConsole

Tracing from your own extension

You can use the console also from your own extension - Firebug doesn't need to be even installed. All you need is the FBTrace extension.

  • Your extension should create a new preference:
pref("extensions.firebug.DBG_MYEXT", false);
  • extensions.firebug.DBG_ prefix is mandatory.
  • As soon as the preference exists you should see a new option MYEXT in the Tracing Console.
  • Get the tracing service in your code.
Components.utils.import("resource://firebug/firebug-trace-service.js");
var FBTrace = traceConsoleService.getTracer("extensions.firebug");

... and create a log:

if (FBTrace.DBG_YOUREXT)
    FBTrace.sysout(string, object);
Personal tools