From e5c50e24f392268039396f352f39c055e9f74588 Mon Sep 17 00:00:00 2001 From: ellemenno Date: Mon, 15 Aug 2016 00:56:00 -0400 Subject: [PATCH 1/7] initial commit --- .gitignore | 6 ++++++ README.md | 4 ++++ 2 files changed, 10 insertions(+) create mode 100644 .gitignore create mode 100644 README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..df723dc --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +bin/ +lib/build/ +logs/ +releases/ +test/bin/ +TEST-*.xml diff --git a/README.md b/README.md new file mode 100644 index 0000000..92bf4c5 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +log-ls +====== + +a simple logging framework for Loom, plus a handy config reader From 422c1f380651ec7018af186bde13cbbda6e44776 Mon Sep 17 00:00:00 2001 From: ellemenno Date: Mon, 15 Aug 2016 00:57:46 -0400 Subject: [PATCH 2/7] add files to repo --- README.md | 112 +++++++++++++++++ Rakefile | 5 + assets/app.config | 7 ++ lib/loom.config | 3 + lib/src/Log.build | 17 +++ lib/src/pixeldroid/util/Config.ls | 100 ++++++++++++++++ lib/src/pixeldroid/util/Log.ls | 180 ++++++++++++++++++++++++++++ lib/src/pixeldroid/util/LogLevel.ls | 92 ++++++++++++++ test/loom.config | 3 + test/src/LogTest.build | 21 ++++ test/src/app/LogTest.ls | 59 +++++++++ test/src/spec/ConfigSpec.ls | 38 ++++++ test/src/spec/LogSpec.ls | 107 +++++++++++++++++ 13 files changed, 744 insertions(+) create mode 100644 Rakefile create mode 100644 assets/app.config create mode 100644 lib/loom.config create mode 100644 lib/src/Log.build create mode 100644 lib/src/pixeldroid/util/Config.ls create mode 100644 lib/src/pixeldroid/util/Log.ls create mode 100644 lib/src/pixeldroid/util/LogLevel.ls create mode 100644 test/loom.config create mode 100644 test/src/LogTest.build create mode 100644 test/src/app/LogTest.ls create mode 100644 test/src/spec/ConfigSpec.ls create mode 100644 test/src/spec/LogSpec.ls diff --git a/README.md b/README.md index 92bf4c5..b6555fc 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,115 @@ log-ls ====== a simple logging framework for Loom, plus a handy config reader + + +## installation + +Download the library into its matching sdk folder: + + $ curl -L -o ~/.loom/sdks/sprint34/libs/Log.loomlib \ + https://github.com/pixeldroid/spec-ls/releases/download/v1.1.5/Log-sprint34.loomlib + +To uninstall, simply delete the file: + + $ rm ~/.loom/sdks/sprint34/libs/Log.loomlib + + +## usage + +### Log + +0. import `Log` (once per class) +0. declare a label (once per class) +0. set the log level (once at app startup, ideally from a config file value) +0. submit a message generator at some verbosity level (`debug`, `info`, `warn`, `error`, `fatal`) + +```ls +package +{ + import loom.Application; + + import pixeldroid.util.Log; + import pixeldroid.util.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 + +0. create a json file named `app.config` in the `assets/` folder of the project root +0. import `Config` +0. retrieve values + +```json +{ + "app_version": "1.0.0", + "log_level": "DEBUG", + "my_string": "string value", + "my_number": 123.456, + "my_integer": 789 +} +``` +> _assets/app.config_ + +```ls +package +{ + import loom.Application; + + import pixeldroid.util.Config; + import pixeldroid.util.Log; + import pixeldroid.util.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.getNumber('my_integer'); }); + } + } +} +``` + +## working from source + +first install [loomtasks][loomtasks] + +### compiling + + $ 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! + + +[loomtasks]: https://github.com/pixeldroid/loomtasks "loomtasks" diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..23e1fef --- /dev/null +++ b/Rakefile @@ -0,0 +1,5 @@ +LIB_NAME = 'Log' +LIB_VERSION_FILE = File.join('lib', 'src', 'pixeldroid', 'util', 'Log.ls') + +load(File.join(ENV['HOME'], '.loom', 'tasks', 'loomlib.rake')) +#load(File.join(ENV['HOME'], '.loom', 'tasks', 'loomlib_demo.rake')) # optional diff --git a/assets/app.config b/assets/app.config new file mode 100644 index 0000000..04e3adb --- /dev/null +++ b/assets/app.config @@ -0,0 +1,7 @@ +{ + "app_version": "0.0.0", + "log_level": "DEBUG", + "string": "string value", + "number": 123.456, + "integer": 789 +} diff --git a/lib/loom.config b/lib/loom.config new file mode 100644 index 0000000..345d99b --- /dev/null +++ b/lib/loom.config @@ -0,0 +1,3 @@ +{ + "sdk_version": "sprint34" +} \ No newline at end of file diff --git a/lib/src/Log.build b/lib/src/Log.build new file mode 100644 index 0000000..353ca36 --- /dev/null +++ b/lib/src/Log.build @@ -0,0 +1,17 @@ +{ + "name": "Log", + "version": "1.0", + "outputDir": "build", + "references": [ + "System" + ], + "modules": [ + { + "name": "Log", + "version": "1.0", + "sourcePath": [ + "." + ] + } + ] +} diff --git a/lib/src/pixeldroid/util/Config.ls b/lib/src/pixeldroid/util/Config.ls new file mode 100644 index 0000000..bde7b73 --- /dev/null +++ b/lib/src/pixeldroid/util/Config.ls @@ -0,0 +1,100 @@ +package pixeldroid.util +{ + import pixeldroid.util.LogLevel; + + /** + Provides access to configuration values defined in assets/app.config + */ + class Config + { + private static var _fileContents:String; + private static var _json:JSON; + + /** + Retrieve the verbosity level to be used for the logging system. + */ + public static function get logLevel():LogLevel + { + var value:String = json.getString('log_level'); + + return LogLevel.fromString(value); + } + + /** + Retrieve the raw contents of the app.config file. + */ + public static function get fileContents():String + { + if (!_fileContents) + { + var filePath:String = 'assets/app.config'; + if (File.fileExists(filePath)) _fileContents = File.loadTextFile(filePath); + else Debug.assertException(new Error("no config file found at '" +filePath +"'")); + } + + return _fileContents; + } + + public static function refresh():void + { + _fileContents = null; + _json.loadString(fileContents); + } + + /** + Retrieve the app version string. + */ + public static function get appVersion():String + { + var value:String = json.getString('app_version'); + + return value; + } + + /** + Retrieve an arbitrary string value from app.config. + */ + public static function getString(key:String):String + { + var value:String = json.getString(key); + + return value; + } + + /** + Retrieve an arbitrary number value from app.config. + Note: the number must be defined with a decimal point. + */ + public static function getNumber(key:String):Number + { + var value:Number = json.getFloat(key); + + return value; + } + + /** + Retrieve an arbitrary integer value from app.config. + */ + public static function getInteger(key:String):Number + { + var value:Number = json.getInteger(key); + + return value; + } + + + private static function get json():JSON + { + if (!_json) + { + _json = new JSON(); + if (!_json.loadString(fileContents)) + { + Debug.assertException(new Error("error parsing json file: '" +_json.getError() +"'")); + } + } + + return _json; + } + } +} diff --git a/lib/src/pixeldroid/util/Log.ls b/lib/src/pixeldroid/util/Log.ls new file mode 100644 index 0000000..ce79030 --- /dev/null +++ b/lib/src/pixeldroid/util/Log.ls @@ -0,0 +1,180 @@ +package pixeldroid.util +{ + import pixeldroid.util.LogLevel; + + /** + Provides methods for sending formatted log messages at various verbosity levels. + + Messages that exceed the current verbosity threshold stored in `level` will be ignored. + + A default formatter is provided. Custom formatters can be used by setting + the value of the `formatter` property to a Formatter-compliant class instance. + + A default printer is provided to log to `Console.print()`. Custom printers + can be used by setting the value of the `printer` property to a Printer- + compliant class instance. + + Logging functions expect a label to indicate the owner of the message, and + a function that should evaluate to a message when called. By capturing the + message construction in a closure, any costs associated with forming the message + are avoided for logging calls above the current verbosity threshold (log level). + */ + class Log + { + public static const version:String = '1.0.0'; + + public static const defaultFormatter:Formatter = new BasicFormatter(); + public static const defaultPrinter:Printer = new ConsolePrinter(); + public static const defaultLevel:LogLevel = new LogLevel(2, 'ERROR'); // need to use constructor, as static initialization of this class is prior to availability of member vars in LogLevel + + public static var formatter:Formatter = defaultFormatter; + public static var printer:Printer = defaultPrinter; + public static var level:LogLevel = defaultLevel; + + /** + Submit a message at debug level verbosity (the highest verbosity level). + + DEBUG messages help isolate problems in running systems, by showing + what is being executed and the execution context. + + DEBUG messages should provide context that makes it easy to spot + abnormal values or conditions. + + @param label Name of the message owner + @param messageGenerator A function to generate the message string + */ + public static function debug(label:String, messageGenerator:Function):void + { + if (level.value >= LogLevel.DEBUG.value) processMessage(LogLevel.DEBUG, label, messageGenerator); + } + + /** + Submit a message at info level verbosity + + INFO messages announce--at a high level--what the running system is doing. + The system should be able to run at full speed with INFO level logging. + + INFO messages should paint a clear picture of normal system operation. + + @param label Name of the message owner + @param messageGenerator A function to generate the message string + */ + public static function info(label:String, messageGenerator:Function):void + { + if (level.value >= LogLevel.INFO.value) processMessage(LogLevel.INFO, label, messageGenerator); + } + + /** + Submit a message at warn level verbosity + + WARN messages signal that something unexpected has occurred; the system + is still operating as expected, but some investigation may be warranted. + + WARN messages should be clear about what expectation was invalidated. + + @param label Name of the message owner + @param messageGenerator A function to generate the message string + */ + public static function warn(label:String, messageGenerator:Function):void + { + if (level.value >= LogLevel.WARN.value) processMessage(LogLevel.WARN, label, messageGenerator); + } + + /** + Submit a message at error level verbosity. + + ERROR messages record that something has gone wrong, the system is unable + to recover, and an operator needs to investigate and fix something. + + ERROR messages should be clear about what went wrong and how it can be triaged or fixed. + + @param label Name of the message owner + @param messageGenerator A function to generate the message string + */ + public static function error(label:String, messageGenerator:Function):void + { + if (level.value >= LogLevel.ERROR.value) processMessage(LogLevel.ERROR, label, messageGenerator); + } + + /** + Submit a message at fatal level verbosity. + + FATAL messages document a failure that prevents the system from starting, + and indicate the system is completely unusable. + + FATAL messages should be clear about what assertion was violated. + + @param label Name of the message owner + @param messageGenerator A function to generate the message string + */ + public static function fatal(label:String, messageGenerator:Function):void + { + if (level.value >= LogLevel.FATAL.value) processMessage(LogLevel.FATAL, label, messageGenerator); + } + + + private static function processMessage(level:LogLevel, label:String, messageGenerator:Function):void + { + // there is also Platform.getEpochTime(), but no Date object, so no conversion to YY, MM, DD, etc. + // since time conversion accounting for leap years is non-trivial, we just use uptime here: + var time:Number = Platform.getTime(); // milliseconds since app launch + var message:String = messageGenerator() as String; + printer.print(formatter.format(time, level, label, message)); + } + } + + /** + Declares a receiver function for use by the logger. + */ + interface Printer + { + /** + @param message The message to be printed to a log receiver + */ + function print(message:String):void; + } + + /** + Declares a message formatting function for use by the logger. + */ + interface Formatter + { + /** + @param time The number of milliseconds since app start + @param level A `LogLevel` constant representing verbosity of the message + @param label A name for the owner of the message + @param message The message to be logged + */ + function format(time:Number, level:LogLevel, label:String, message:String):String; + } + + + class ConsolePrinter implements Printer + { + public function print(message:String):void + { + Console.print(message); + } + } + + class BasicFormatter implements Formatter + { + public function format(time:Number, level:LogLevel, label:String, message:String):String + { + var h:Number = Math.floor(time / (60 * 60 * 1000)); + time -= h * (60 * 60 * 1000); + var m:Number = Math.floor(time / (60 * 1000)); + time -= m * (60 * 1000); + var s:Number = Math.floor(time / 1000); + time -= s * 1000; + var l:Number = time; + + var hh:String = String.lpad(h.toString(), '0', 2); + var mm:String = String.lpad(m.toString(), '0', 2); + var ss:String = String.lpad(s.toString(), '0', 2); + var ll:String = String.lpad(l.toString(), '0', 3); + + return hh +':' + mm + ':' + ss + '.' + ll + ' [' + String.lpad(level.toString(), ' ', 5) + '] ' + label + ': ' + message; + } + } +} diff --git a/lib/src/pixeldroid/util/LogLevel.ls b/lib/src/pixeldroid/util/LogLevel.ls new file mode 100644 index 0000000..a4274a0 --- /dev/null +++ b/lib/src/pixeldroid/util/LogLevel.ls @@ -0,0 +1,92 @@ +package pixeldroid.util +{ + /** + Enumerates the verbosity levels of the logging system, from `NONE` (least verbose) to `DEBUG` (most verbose). + + The order of increasing verbosity is: `NONE` > `FATAL` > `ERROR` > `WARN` > `INFO` > `DEBUG`. + + * `NONE` indicates no logging should occur. + * `FATAL` allows only messages related to application crashes. + * `ERROR` adds messages related to unexpected results that will break expected behavior. + * `WARN` adds messages related to unexpected results that will not break expected behavior. + * `INFO` adds messages that track happy path execution. + * `DEBUG` adds messages that track program state. + + All LogLevel values have both a human readable string value (`label`), as well as a machine-comparable numeric value (`value`). + */ + class LogLevel + { + public static const NONE:LogLevel = new LogLevel(0, 'NONE'); + public static const FATAL:LogLevel = new LogLevel(1, 'FATAL'); + public static const ERROR:LogLevel = new LogLevel(2, 'ERROR'); + public static const WARN:LogLevel = new LogLevel(3, 'WARN'); + public static const INFO:LogLevel = new LogLevel(4, 'INFO'); + public static const DEBUG:LogLevel = new LogLevel(5, 'DEBUG'); + + /** + Create a LogLevel instance from a label. + + @param value A string matching one of [NONE, FATAL, ERROR, WARN, INFO, DEBUG] + */ + public static function fromString(value:String):LogLevel + { + switch (value.toUpperCase()) + { + case 'NONE' : return NONE; + case 'FATAL': return FATAL; + case 'ERROR': return ERROR; + case 'WARN' : return WARN; + case 'INFO' : return INFO; + case 'DEBUG': return DEBUG; + } + return NONE; + } + + /** + Test for interchangeablility between LogLevel instances. + + Two different instantiations of LogLevel will not formally equate to each other, + but can be considered equivalent if they represent the same log level. + + This method is a convenience for testing that value and label are the same on both instances. + + @param a An instance of LogLevel + @param b An instance of LogLevel to compare against instance a + */ + public static function areEquivalent(a:LogLevel, b:LogLevel):Boolean + { + if (a.value != b.value) return false; + if (a.label != b.label) return false; + return true; + } + + + private var _level:Number; + private var _label:String; + + public function LogLevel(level:Number, label:String) + { + _level = level; + _label = label; + } + + /** + Request a human-readable representation of the logging level. + + This is equivalent to the label. + */ + public function toString():String { return _label; } + + /** + Request a string representation of the logging level. + */ + public function get label():String { return _label; } + + /** + Request a numerical representation of the logging level. + + Level values can be compared to each other, with higher values being more verbose. + */ + public function get value():Number { return _level; } + } +} diff --git a/test/loom.config b/test/loom.config new file mode 100644 index 0000000..345d99b --- /dev/null +++ b/test/loom.config @@ -0,0 +1,3 @@ +{ + "sdk_version": "sprint34" +} \ No newline at end of file diff --git a/test/src/LogTest.build b/test/src/LogTest.build new file mode 100644 index 0000000..8d3cea7 --- /dev/null +++ b/test/src/LogTest.build @@ -0,0 +1,21 @@ +{ + "name": "LogTest", + "version": "1.0", + "outputDir": "bin", + "references": [ + "System", + "Spec", + "Log" + ], + "modules": [ + { + "name": "LogTest", + "version": "1.0", + "sourcePath": [ + "app", + "spec" + ] + } + ], + "executable": true +} diff --git a/test/src/app/LogTest.ls b/test/src/app/LogTest.ls new file mode 100644 index 0000000..b9f8b88 --- /dev/null +++ b/test/src/app/LogTest.ls @@ -0,0 +1,59 @@ +package +{ + + import system.Process; + import system.application.ConsoleApplication; + + import pixeldroid.bdd.Spec; + import pixeldroid.bdd.Reporter; + import pixeldroid.bdd.reporters.AnsiReporter; + import pixeldroid.bdd.reporters.ConsoleReporter; + import pixeldroid.bdd.reporters.JunitReporter; + + import ConfigSpec; + import LogSpec; + + + public class LogTest extends ConsoleApplication + { + private var seed:Number = -1; + private const SUCCESS:Number = 0; + private const FAILURE:Number = 1; + + override public function run():void + { + ConfigSpec.describe(); + LogSpec.describe(); + + parseArgs(); + Process.exit(Spec.execute(seed) ? SUCCESS : FAILURE); + } + + private function parseArgs():void + { + var arg:String; + for (var i = 0; i < CommandLine.getArgCount(); i++) + { + arg = CommandLine.getArg(i); + if (arg == '--format') Spec.addReporter(reporterByName(CommandLine.getArg(++i))); + if (arg == '--seed') seed = Number.fromString(CommandLine.getArg(++i)); + } + + if (Spec.numReporters == 0) Spec.addReporter(new ConsoleReporter()); + } + + private function reporterByName(name:String):Reporter + { + var r:Reporter; + + switch (name.toLowerCase()) + { + case 'ansi': r = new AnsiReporter(); break; + case 'console': r = new ConsoleReporter(); break; + case 'junit': r = new JunitReporter(); break; + } + + return r; + } + } +} diff --git a/test/src/spec/ConfigSpec.ls b/test/src/spec/ConfigSpec.ls new file mode 100644 index 0000000..4fff38f --- /dev/null +++ b/test/src/spec/ConfigSpec.ls @@ -0,0 +1,38 @@ +package +{ + import pixeldroid.bdd.Spec; + import pixeldroid.bdd.Thing; + + import pixeldroid.util.Config; + + public static class ConfigSpec + { + public static function describe():void + { + Config.fileContents; // force instantiation and file load + + var it:Thing = Spec.describe('Config'); + + it.should('provide access to the app version', function() { + it.expects(Config.appVersion).toEqual('0.0.0'); + }); + + it.should('provide access to the log level', function() { + it.expects(Config.logLevel.toString()).toEqual('DEBUG'); + }); + + it.should('provide access to string values', function() { + it.expects(Config.getString('string')).toEqual('string value'); + }); + + it.should('provide access to number values', function() { + it.expects(Config.getNumber('number')).toEqual(123.456); + }); + + it.should('provide access to integer values', function() { + it.expects(Config.getInteger('integer')).toEqual(789); + }); + + } + } +} diff --git a/test/src/spec/LogSpec.ls b/test/src/spec/LogSpec.ls new file mode 100644 index 0000000..6de74bd --- /dev/null +++ b/test/src/spec/LogSpec.ls @@ -0,0 +1,107 @@ +package +{ + import pixeldroid.bdd.Spec; + import pixeldroid.bdd.Thing; + + import pixeldroid.util.Log; + import pixeldroid.util.LogLevel; + import pixeldroid.util.Printer; + + public static class LogSpec + { + public static function describe():void + { + var testPrinter:TestPrinter = new TestPrinter(); + var defaultLevel:LogLevel = Log.level; + Log.printer = testPrinter; + + var it:Thing = Spec.describe('Log'); + + it.should('default to ERROR level logging', function() { + it.expects(LogLevel.areEquivalent(defaultLevel, LogLevel.ERROR)).toBeTruthy(); + }); + + it.should('provide a default format for time, level, label, and message', function() { + var lastLevel:LogLevel = Log.level; + Log.level = LogLevel.INFO; + + Log.info('LogSpec', function():String { return 'info message'; }); + + // Loom uses Lua regex patterns: + // http://lua-users.org/wiki/PatternsTutorial + // http://www.lua.org/manual/5.2/manual.html#6.4.1 + var time:String = '^(%d%d:%d%d:%d%d.%d%d%d)'; + var level:String = '%s(%[%s?%u+%])'; + var label:String = '%s(.*:)'; + var message:String = '%s(.*)$'; + + it.expects(testPrinter.lastMessage).toPatternMatch(time +level +label +message, 4); + + Log.level = lastLevel; + }); + + it.should('provide a set of increasing verbosity levels', function() { + it.expects(LogLevel.NONE.value ).toBeLessThan(LogLevel.FATAL.value); + it.expects(LogLevel.FATAL.value).toBeLessThan(LogLevel.ERROR.value); + it.expects(LogLevel.ERROR.value).toBeLessThan(LogLevel.WARN.value); + it.expects(LogLevel.WARN.value ).toBeLessThan(LogLevel.INFO.value); + it.expects(LogLevel.INFO.value ).toBeLessThan(LogLevel.DEBUG.value); + }); + + it.should('not log messages above the current log level', function() { + var lastLevel:LogLevel = Log.level; + Log.level = LogLevel.INFO; + + Log.warn('LogSpec', function():String { return 'warn message'; }); + it.expects(testPrinter.lastMessage).not.toBeEmpty(); + + Log.debug('LogSpec', function():String { return 'debug message'; }); + it.expects(testPrinter.lastMessage).toBeEmpty(); + + Log.level = LogLevel.NONE; + Log.fatal('LogSpec', function():String { return 'fatal message'; }); + Log.error('LogSpec', function():String { return 'error message'; }); + Log.warn ('LogSpec', function():String { return 'warn message'; }); + Log.info ('LogSpec', function():String { return 'info message'; }); + Log.debug('LogSpec', function():String { return 'debug message'; }); + it.expects(testPrinter.lastMessage).toBeEmpty(); + + Log.level = lastLevel; + }); + + it.should('not compute messages that are not logged', function() { + var lastLevel:LogLevel = Log.level; + var initialValue:Number = 0; + var captive:Number = initialValue; + + Log.level = LogLevel.INFO; + Log.debug('LogSpec', function():String { captive++; return 'debug message executed'; }); + it.expects(captive).toEqual(initialValue); + + Log.level = LogLevel.DEBUG; + Log.debug('LogSpec', function():String { captive++; return 'debug message executed'; }); + it.expects(captive).toEqual(initialValue + 1); + + Log.level = lastLevel; + }); + } + } + + class TestPrinter implements Printer + { + private var printedMessage:String = ''; + + public function print(message:String):void + { + printedMessage = message; + } + + public function get lastMessage():String + { + var m:String = printedMessage; + printedMessage = ''; + + return m; + } + } +} From 4fcc154aac94bbfd6b87650c09967c49c350018e Mon Sep 17 00:00:00 2001 From: ellemenno Date: Mon, 15 Aug 2016 22:03:14 -0400 Subject: [PATCH 3/7] correct minor doc comment issues --- README.md | 2 +- lib/src/pixeldroid/util/Config.ls | 5 ++++- lib/src/pixeldroid/util/LogLevel.ls | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b6555fc..4290953 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ package 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.getNumber('my_integer'); }); + Log.info(_logName, function():String { return 'my integer: ' +Config.getInteger('my_integer'); }); } } } diff --git a/lib/src/pixeldroid/util/Config.ls b/lib/src/pixeldroid/util/Config.ls index bde7b73..c6baffd 100644 --- a/lib/src/pixeldroid/util/Config.ls +++ b/lib/src/pixeldroid/util/Config.ls @@ -3,7 +3,7 @@ package pixeldroid.util import pixeldroid.util.LogLevel; /** - Provides access to configuration values defined in assets/app.config + Provides access to configuration values defined in `assets/app.config`. */ class Config { @@ -35,6 +35,9 @@ package pixeldroid.util return _fileContents; } + /** + Reload the config values from file. + */ public static function refresh():void { _fileContents = null; diff --git a/lib/src/pixeldroid/util/LogLevel.ls b/lib/src/pixeldroid/util/LogLevel.ls index a4274a0..d2c47b9 100644 --- a/lib/src/pixeldroid/util/LogLevel.ls +++ b/lib/src/pixeldroid/util/LogLevel.ls @@ -43,7 +43,7 @@ package pixeldroid.util } /** - Test for interchangeablility between LogLevel instances. + Test for interchangeability between LogLevel instances. Two different instantiations of LogLevel will not formally equate to each other, but can be considered equivalent if they represent the same log level. From dd5715dc601f7e410129c7a46fdc04a313bda333 Mon Sep 17 00:00:00 2001 From: ellemenno Date: Sat, 27 Aug 2016 22:55:32 -0400 Subject: [PATCH 4/7] correct typo in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4290953..372f809 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ a simple logging framework for Loom, plus a handy config reader Download the library into its matching sdk folder: $ curl -L -o ~/.loom/sdks/sprint34/libs/Log.loomlib \ - https://github.com/pixeldroid/spec-ls/releases/download/v1.1.5/Log-sprint34.loomlib + https://github.com/pixeldroid/log-ls/releases/download/v1.1.5/Log-sprint34.loomlib To uninstall, simply delete the file: From 96d9ff80916ee818ef7e0e185bf022b1a7f3bac2 Mon Sep 17 00:00:00 2001 From: ellemenno Date: Sat, 27 Aug 2016 22:56:22 -0400 Subject: [PATCH 5/7] add rescue block for loomtasks --- Rakefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index 23e1fef..f857575 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,12 @@ LIB_NAME = 'Log' LIB_VERSION_FILE = File.join('lib', 'src', 'pixeldroid', 'util', 'Log.ls') -load(File.join(ENV['HOME'], '.loom', 'tasks', 'loomlib.rake')) -#load(File.join(ENV['HOME'], '.loom', 'tasks', 'loomlib_demo.rake')) # optional +begin + load(File.join(ENV['HOME'], '.loom', 'tasks', 'loomlib.rake')) +rescue LoadError + abort([ + 'error: missing loomlib.rake', + ' please install loomtasks before running this Rakefile:', + ' https://github.com/pixeldroid/loomtasks/', + ].join("\n")) +end From 815674ac5ac9ac1e1ffb8c37bea45366ce6ef5e5 Mon Sep 17 00:00:00 2001 From: ellemenno Date: Sat, 27 Aug 2016 23:14:43 -0400 Subject: [PATCH 6/7] make doc comment less confusing assume people will read angle brackets as math operators and not arrows, so flip them to read correctly as 'less-than' --- lib/src/pixeldroid/util/LogLevel.ls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/pixeldroid/util/LogLevel.ls b/lib/src/pixeldroid/util/LogLevel.ls index d2c47b9..ff96c41 100644 --- a/lib/src/pixeldroid/util/LogLevel.ls +++ b/lib/src/pixeldroid/util/LogLevel.ls @@ -3,7 +3,7 @@ package pixeldroid.util /** Enumerates the verbosity levels of the logging system, from `NONE` (least verbose) to `DEBUG` (most verbose). - The order of increasing verbosity is: `NONE` > `FATAL` > `ERROR` > `WARN` > `INFO` > `DEBUG`. + The order of increasing verbosity is: `NONE` < `FATAL` < `ERROR` < `WARN` < `INFO` < `DEBUG`. * `NONE` indicates no logging should occur. * `FATAL` allows only messages related to application crashes. From 0ded261b826baab363c7ff0cd43fdd6325a0e5b4 Mon Sep 17 00:00:00 2001 From: ellemenno Date: Sat, 27 Aug 2016 23:15:40 -0400 Subject: [PATCH 7/7] prepare for release --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 372f809..0fc60be 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ a simple logging framework for Loom, plus a handy config reader 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/v1.1.5/Log-sprint34.loomlib + https://github.com/pixeldroid/log-ls/releases/download/v1.0.0/Log-sprint34.loomlib To uninstall, simply delete the file: