On-device console logging

  • Revision slug: Mozilla/Firefox_OS/Debugging/On-device_console_logging
  • Revision title: On-device console logging
  • Revision id: 447921
  • Created:
  • Creator: breck
  • Is current revision? No
  • Comment Would really like this feature, and not sure if it's currently being worked on.

Revision Content

In addition to being able to log console output and view it using the remote web console, you can log console output into the device's onboard file store, then retrieve the logs later from your computer using the logcat utility and a USB connection. This article covers how to enable this feature, how to perform the logging, and how to retrieve the logs.

Enabling console logging

On production builds of Firefox OS, console logging (such as by {{domxref("console.log()")}}) is disabled by default. In order to enable it, open the Settings app and navigate down through Device Information->More Information->Developer, then toggle on the "Console Enabled" preference.

Logging

Once logging has been enabled, it works just like logging on desktop Firefox OS. You simply use the methods on the {{domxref("console")}} object to log text to the console. For example:

console.info("Starting up the foobar hardware!"
var err = foobar.start();
if (err) {
  console.error("--Error %d starting up the foobar hardware!", err);
}

See {{domxref("console")}} for details on logging features available to you.

Using logcat

Because the log output is stored on the Firefox OS device, and there isn't currently any user interface for viewing these logs on the device, you'll need to fetch them to a computer for review. The bug for building a feature to view these logs on the device is located here: http://foo.com. You'll need to use the logcat command from adb, which is part of the Android SDK that you probably have already installed as part of preparing to develop for and on Firefox OS.

 

Revision Source

<p>In addition to being able to log console output and view it using the <a href="/en-US/docs/Mozilla/Firefox_OS/Debugging/Using_the_Remote_Web_Console" title="/en-US/docs/Mozilla/Firefox_OS/Debugging/Using_the_Remote_Web_Console">remote web console</a>, you can log console output into the device's onboard file store, then retrieve the logs later from your computer using the <a href="http://developer.android.com/tools/help/logcat.html" title="http://developer.android.com/tools/help/logcat.html"><code>logcat</code></a> utility and a USB connection. This article covers how to enable this feature, how to perform the logging, and how to retrieve the logs.</p>
<h2 id="Enabling_console_logging">Enabling console logging</h2>
<p>On production builds of Firefox OS, console logging (such as by {{domxref("console.log()")}}) is disabled by default. In order to enable it, open the Settings app and navigate down through Device Information-&gt;More Information-&gt;Developer, then toggle on the "Console Enabled" preference.</p>
<h2 id="Logging">Logging</h2>
<p>Once logging has been enabled, it works just like logging on desktop Firefox OS. You simply use the methods on the {{domxref("console")}} object to log text to the console. For example:</p>
<pre class="brush: js">
console.info("Starting up the foobar hardware!"
var err = foobar.start();
if (err) {
  console.error("--Error %d starting up the foobar hardware!", err);
}
</pre>
<p>See {{domxref("console")}} for details on logging features available to you.</p>
<h2 id="Using_logcat">Using logcat</h2>
<p>Because the log output is stored on the Firefox OS device, and there isn't currently any user interface for viewing these logs on the device, you'll need to fetch them to a computer for review. The bug for building a feature to view these logs on the device is located here: http://foo.com. You'll need to use the <code>logcat</code> command from <code>adb</code>, which is part of the Android SDK that you probably have already installed as part of preparing to develop for and on Firefox OS.</p>
<p>&nbsp;</p>
Revert to this revision