Debugging

Matt Karl edited this page Jan 13, 2015 · 2 revisions

Debug is a class which extends the native console object and provides a bunch of extra features. For the most part any console method is available in Debug. For instance, Debug.log works similarly to console.log.

Convenience Colors

There are a bunch of convenience methods to output a log as a pre-defined color. For instance, Debug.green('Just like the trees'); will output the message in green. Here are the full list of supported colors: aqua, green, orange, blue, purple, red, lime, silver, teal, maroon, navy, gray, olive, yellow.

Chaining

Like many modern JavaScript libraries, Debug supports the chain of methods together.

Debug.log('Something')
     .info('more details')
     .log({ id: 100 });

Substitution Variables

Like console, Debug supports the substitution variables like %s for strings. Note that substitution variables do not

Debug.log("Hi %s, my name is %s", 'world', 'Joe',);
// "Hi world, my name is Joe."

Remote Debugging

Remote debugging allows the developer to send console logs over a network on internet connection. While modern versions of browsers now support remote debugging over a USB cable, there are some scenarios where either the desktop or device don't support debugging this way, such as early versions of the Android stock browser.

To use remote debugging without USB, you'll need to install and launch SpringRoll Studio on the computer that will receive your logs. Please download the appropriate binary for your platform.

Both the device you're debugging on and the computer with SpringRoll Studio installed need to be on the same local area network.

Make sure that debug and debugRemote are set as Application options when your application is created. For instance:

var app = new Application({
	debug: true,
	debugRemote: '192.168.1.2' // either IP address or host name (e.g. "localhost")
});

Now whenever logs are sent with the Debug class, they will be outputted to the Remote Trace program inside SpringRoll Studio.

Debug.log("General trace");
Debug.debug("Debugging trace");
Debug.info("Informational trace");
Debug.warn("Warning trace");
Debug.error("Error or fatal trace");

Remote Trace Preview