prioritized, tagged Android logging in Fennec JavaScript

Myk Melez myk at
Mon May 12 09:09:01 PDT 2014


I just landed bug 1004825, which adds prioritized, tagged logging to the 
JavaScript code in Fennec with an API that resembles android.util.Log.

To use it, import the module and then call its v, d, i, w, or e functions:

let Log = Cu.import("resource://gre/modules/AndroidLog.jsm", {}).AndroidLog;
Log.v("MyModule", "This is a verbose message.");
Log.d("MyModule", "This is a debug message.");
Log.i("MyModule", "This is an info message.");
Log.w("MyModule", "This is a warning message.");
Log.e("MyModule", "This is an error message.");

And bind Log.d with a tag to replace bespoke dump/log/debug functions:

let debug = Log.d.bind(null, "MyModule");
debug("This is a debug message with a MyModule tag.");

Tags automatically have "Gecko" prepended to them, and I've replaced the 
dump function in browser.js with a Log.d binding, so its messages are 
now logged at the debug level and with the GeckoBrowser tag.

See the module source for more docs!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the mobile-firefox-dev mailing list