bunyan
bunyan copied to clipboard
Dev
Still in draft form - but the tests pass. Created an option -c (compare) based on the description of the node version of bunyan. Currently implemented for a few of the easy base JSON fields. Constrained to the comparison operators, rather than "any javascript" the node version allows. Intend on expanding to include the JSON in the "extra" field as well.
Not sure the effort to create types for the comparison is necessary - as that will not be possible for the free-form JSON in the extra field. Might need to simplify this down to just String comparisons.
Finally found the time to have a look - it looks quite promising! A few comments:
- The parsing of the comparison condition should happen once, at the beginning, not every time you need to check if a line matches the condition;
- As you noted, we need something more dynamic to handle the
extrakeys, which is where the real fun begins; - Does the JS version of
bunyanallow chaining of comparisons? I.e.x == 2 && y == 3?
Thanks for the feedback!
The JS version of bunyan allows an “arbitrary JS expression” for a filter. One of the advantages of a dynamic language! I started with a simple one-field comparison to get started, a chain of comparisons would be a logical next step – but I don’t know if defining a “language” for something more complicated than that would be worth the effort.