Titanium JIRA Archive
Alloy (ALOY)

[ALOY-780] Support DEBUG compiler constant

GitHub Issuen/a
TypeNew Feature
PriorityMedium
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sAlloy 2.0.0
ComponentsRuntime, Tooling
Labelsn/a
ReporterTony Lukasavage
AssigneeUnknown
Created2013-08-12T17:19:05.000+0000
Updated2018-03-07T22:25:44.000+0000

Description

Add DEBUG as a compiler conditional, like OS_ANDROID or ENV_TEST. This should be false by default and configurable through the config.json. This should be used for logging or other operations that you want to be able to see regardless of deploy type, but only when debugging.

config.json

{
  "DEBUG": true
}

index.js

// assuming we have a "collection" with lots of models...

for (var i = 0; i < collection.length; i+) {
    var model = collection.at(i);

    // perform critical operation

    // If DEBUG=true, leave this in the code. If it is false, remove this at compile time.
    // Good for things like logging or other expensive, non-essential debugging operations.
    if (DEBUG) {
        Ti.API.info(JSON.stringify(model.attributes, null, '  '));
    }
}

Comments

No comments

JSON Source