[ALOY-780] Support DEBUG compiler constant
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Medium |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | Alloy 2.0.0 |
Components | Runtime, Tooling |
Labels | n/a |
Reporter | Tony Lukasavage |
Assignee | Unknown |
Created | 2013-08-12T17:19:05.000+0000 |
Updated | 2018-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, ' '));
}
}
No comments