issue #31: foudn a solution to the bleeding defines using idea from dap. re-instate LEVEL defines in bunyan '-c' code
This commit is contained in:
parent
d3bdcb54da
commit
31d7e3477a
2 changed files with 13 additions and 3 deletions
|
@ -1,8 +1,11 @@
|
||||||
# bunyan Changelog
|
# 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
|
## bunyan 0.12.0
|
||||||
|
|
|
@ -329,6 +329,13 @@ function parseArgv(argv) {
|
||||||
}
|
}
|
||||||
args = newArgs;
|
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;
|
var endOfOptions = false;
|
||||||
while (args.length > 0) {
|
while (args.length > 0) {
|
||||||
var arg = args.shift();
|
var arg = args.shift();
|
||||||
|
@ -388,7 +395,7 @@ function parseArgv(argv) {
|
||||||
var condition = args.shift();
|
var condition = args.shift();
|
||||||
parsed.conditions = parsed.conditions || [];
|
parsed.conditions = parsed.conditions || [];
|
||||||
var scriptName = 'bunyan-condition-'+parsed.conditions.length;
|
var scriptName = 'bunyan-condition-'+parsed.conditions.length;
|
||||||
var script = vm.createScript(condition, scriptName);
|
var script = vm.createScript(condDefines + condition, scriptName);
|
||||||
parsed.conditions.push(script);
|
parsed.conditions.push(script);
|
||||||
break;
|
break;
|
||||||
default: // arguments
|
default: // arguments
|
||||||
|
|
Loading…
Reference in a new issue