prioritized, tagged Android logging in Fennec JavaScript

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


Mobillians!

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

https://bugzilla.mozilla.org/show_bug.cgi?id=1004825

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!

http://mxr.mozilla.org/mozilla-central/source/mobile/android/modules/AndroidLog.jsm

-myk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/mobile-firefox-dev/attachments/20140512/39e500fb/attachment.html>


More information about the mobile-firefox-dev mailing list