Debug Module

Matt Karl edited this page Sep 25, 2015 · 3 revisions

Debug module which mainly consists of springroll.Debug which extends console to provide some useful features for remote debugging, outputting different colors, and cross-platform compatibility.

Dependencies

Installing

In order to use the Debug module, make sure to include the module's JavaScript and CSS file within your springroll.json project file under librariesDebug. Note that Debug should generally not be included in the libraries since we don't want to include Debug for release.

"libraries": [
	"components/springroll/dist/core.min.js",
	"components/springroll/dist/core.min.css"
],
"librariesDebug": [
	"components/springroll/dist/core.js",
	"components/springroll/dist/core.css",
	"components/springroll/dist/modules/debug.js",
	"components/springroll/dist/modules/debug.css"
]

Application Plugin

Options

options.debug=true (Boolean) If the debugging should be turned out, default is true.

options.debugRemote (String) The IP address or host name to use for remote debugging with SpringRoll Studio

options.framerate="framerate" (String, DOMElement) The DOM element ID or the DOM element used to display the output framerate.

options.minLogLevel=0 (int) The minimum log level to display. 4 is only errors, 3 is warnings and errors, 2 is info, warnings and errors, 1 is everything except general logs, 0 is everything.

Usage

Usage is basically the same as console and supports these standard methods except these methods can easily sent to remote debugger built into SpringRoll Studio.

  • assert
  • clear
  • debug
  • dir
  • error
  • group
  • groupCollapsed
  • groupEnd
  • info
  • log
  • trace
  • warn

Debug also contains a bunch of convenience methods similar to log except they output in a specific color.

  • aqua
  • blue
  • gray
  • green
  • lime
  • maroon
  • navy
  • olive
  • orange
  • pink
  • purple
  • red
  • silver
  • teal
  • yellow

Using Remote Debugging

Setup the remote debugging by adding a debugRemote option to your Application which specifies the host name or IP address of the computer running SpringRoll Studio on your network.

var Application = include('springroll.Application');
var Debug = include('springroll.Debug');

var app = new Application({
	// Send all Debug calls to remote IP
	debugRemote: '127.0.0.1' 
});

app.once('init', function()
{
	Debug.silver("Welcome!"); // sent to remote
	Debug.disconnect(); // turn off remote debugging
	Debug.log("Something else..."); // sent to local console
});

API Documentation

See the documentation for Debug.