a simple logging utility for Loom, plus a handy config reader
view the docs at https://pixeldroid.com/log-ls/
Download the library into its matching sdk folder:
$ curl -L -o ~/.loom/sdks/sprint34/libs/Log.loomlib \
https://github.com/pixeldroid/log-ls/releases/download/v3.0.0/Log-sprint34.loomlib
To uninstall, simply delete the file:
$ rm ~/.loom/sdks/sprint34/libs/Log.loomlib
- import
Log
(once per class) - declare a label (once per class)
- set the log level (once at app startup, ideally from a config file value)
- submit a message generator at some verbosity level (
debug
,info
,warn
,error
,fatal
)
package
{
import loom.Application;
import pixeldroid.util.log.Log;
import pixeldroid.util.log.LogLevel;
public class LogTest extends Application
{
private const _logName:String = getFullTypeName();
override public function run():void
{
Log.level = LogLevel.INFO;
Log.info(_logName, function():String { return _logName +' is running!'; });
}
}
}
- create a json file named
app.config
in theassets/
folder of the project root - import
Config
- retrieve values
{
"app_version": "1.0.0",
"log_level": "DEBUG",
"my_string": "string value",
"my_number": 123.456,
"my_integer": 789
}
assets/app.config
package
{
import loom.Application;
import pixeldroid.util.config.Config;
import pixeldroid.util.log.Log;
import pixeldroid.util.log.LogLevel;
public class ConfigTest extends Application
{
private const _logName:String = getFullTypeName();
override public function run():void
{
Log.level = LogLevel.INFO;
Log.info(_logName, function():String { return 'app version: ' +Config.appVersion; });
Log.info(_logName, function():String { return 'log level: ' +Config.logLevel; });
Log.info(_logName, function():String { return 'my string: ' +Config.getString('my_string'); });
Log.info(_logName, function():String { return 'my number: ' +Config.getNumber('my_number'); });
Log.info(_logName, function():String { return 'my integer: ' +Config.getInteger('my_integer'); });
}
}
}
first, install loomtasks and the spec-ls library
$ rake lib:install
this will build the Log library and install it in the currently configured sdk
$ rake test
this will build the Log library, install it in the currently configured sdk, build the test app, and run the test app.
Pull requests are welcome!