diff --git a/CHANGES.md b/CHANGES.md index 9c1f6a4..5b17325 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,8 +1,11 @@ # bunyan Changelog -## bunyan 0.12.1 (not yet released) +## bunyan 0.13.0 (not yet released) -(nothing yet) +- [issue #31] Re-instate defines for the (uppercase) log level names (TRACE, + DEBUG, etc.) in `bunyan -c "..."` filtering condition code. E.g.: + + $ ... | bunyan -c 'level >= ERROR' ## bunyan 0.12.0 diff --git a/bin/bunyan b/bin/bunyan index 68c8ed5..467d615 100755 --- a/bin/bunyan +++ b/bin/bunyan @@ -329,6 +329,13 @@ function parseArgv(argv) { } args = newArgs; + var condDefines = []; + Object.keys(upperNameFromLevel).forEach(function (lvl) { + condDefines.push( + format("Object.prototype.%s = %s;", upperNameFromLevel[lvl], lvl)); + }); + condDefines = condDefines.join('\n') + '\n'; + var endOfOptions = false; while (args.length > 0) { var arg = args.shift(); @@ -388,7 +395,7 @@ function parseArgv(argv) { var condition = args.shift(); parsed.conditions = parsed.conditions || []; var scriptName = 'bunyan-condition-'+parsed.conditions.length; - var script = vm.createScript(condition, scriptName); + var script = vm.createScript(condDefines + condition, scriptName); parsed.conditions.push(script); break; default: // arguments