Skip to content

a simple logging utility for Loom, plus a handy config reader

License

Notifications You must be signed in to change notification settings

pixeldroid/log-ls

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

log-ls

a simple logging utility for Loom, plus a handy config reader

view the docs at https://pixeldroid.com/log-ls/

installation

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

usage

Log

  1. import Log (once per class)
  2. declare a label (once per class)
  3. set the log level (once at app startup, ideally from a config file value)
  4. 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!'; });
        }
    }
}

Config

  1. create a json file named app.config in the assets/ folder of the project root
  2. import Config
  3. 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'); });
        }
    }
}

building

first, install loomtasks and the spec-ls library

compiling from source

$ rake lib:install

this will build the Log library and install it in the currently configured sdk

running tests

$ rake test

this will build the Log library, install it in the currently configured sdk, build the test app, and run the test app.

contributing

Pull requests are welcome!