Update July 14, 2016: Ouralabs has shutdown their service. If you are still looking for a logging solution you can check out LogEntries.com.

At work we use the Crashlytics crash reporting feature of the Fabric.io suite of tools. Basically, it takes care of reporting any fatal application crashes and uploads the stack trace of all the threads along with other device metrics to help us troubleshoot crashes. It's an excellent service and definitely worth a look if you don't have your own crash reporting service yet.

We found ourselves also wanting to obtain standard info, warnings, and debug log statements from the application in addition to fatal crash data. Having non-fatal logs in real time is useful, as it allows us access to logs from our QA team's devices or even from our own devices during development.

While looking for a solution I came across an excellent service by Ouralabs. Self described as a centralized remote logging platform, it provides a bunch of useful features:

  • Searchable logs by device
  • Ability to adjust the log level (e.g. info, warn, error, etc.) on the fly
  • Ability to live tail the logs for a particular device

The website provides a better overview, so you should go check it out now!

Ouralabs provides SDKs for both Android and iOS. However, we use Cordova, and there wasn't a Cordova plugin that I could find. I went ahead and created one.

Full documentation is available via the readme on GitHub, but I've also included a quick start below.

Quick Start

To get started, you'll need to create a free account at ouralabs.com/signup. Once you've got your log channel set up, you can add the plugin to your Cordova project. The following will install the plugin via the npm registry.

$ cd your-cordova-project
$ cordova plugin add cordova-plugin-ouralabs

Next, you'll need to initialize the plugin in your device ready event, passing in the channel key for the log channel you created in Ouralabs.

  function() {
    // Init success :)
  function(err) {
    // Init failure :(

Before you start logging, you may want to fill in some metadata about the device and/or the current user (user ID or e-mail) of the application so you can correlate the logs to the user account in your system. You can do so by setting attributes:

 setAttributes(userId, userName, pushToken);

Now you can add logging statements, like so, and you'll be able to see them in real time via the live tail in your Ouralabs dashboard:

// Longhand for logging an error message.
OuralabsPlugin.log(OuralabsPlugin.LogLevels.ERROR, "my_function", "Something went horribly wrong", event);

// Shorthand for logging an informational message.
OuralabsPlugin.logInfo("my_function", "It was called.");  

If you use TypeScript, you'll also want to take advantage of the type definition located in the typings directory.

Finally, the plugin includes functionality to hook all existing console.log(...) (and their variants) to funnel logs through to Ouralabs. This is useful for third party frameworks/code that you do not control, or to keep you from sweeping all of your existing log statements.

All of this and more is fully documented in the readme.