Module: UWA/Class/Debug

UWA/Class/Debug

Classes implementing or extending this Class will have extra methods to handle debug.

Example

define('MyProject/Class/TaskList', [
    'UWA/Class',
    'UWA/Class/Debug'
], function (Class, Debug) {

    var TaskList = Class.extend(Debug, {

        init: function () {

            // Add elements storage
            this.elements = {};
        },

        addElement: function(name, value) {

            // Display debug info using log method.
            this.log(UWA.String.format('addElement name={0}, value={1}', name, value));

            this.elements[name] = value;
        }
    });

    return TaskList;
});

require(['MyProject/Class/TaskList'], function (TaskList) {

var myTaskList = new TaskList();

// Enable debug mode, that will enable log output into the console.
myTaskList.setDebugMode(true);

// Call addElement
myTaskList.addElement('buy beer', 'duff');

});

Index

Members

Methods

Members

<inner> debugMode :Boolean

The debug mode flag for the widget. The default value is false. When true, messages written with log method will appear in the console debug.

Type
  • Boolean

Methods

<inner> setDebugMode(mode) → {this}

Set the debugMode of the instance.

Parameters
Name Type Description
mode boolean

true to enable debug else false

Returns
Type
this

<inner> log(message) → {this}

Logs instance's messages in the console if the debugMode is true. It is using UWA.log which usually works with Firebug, Safari and Opera.

Example
widget.log("Widget is loading");
Parameters
Name Type Description
message String

The message to display in the console debug

Returns
Type
this