Skip to content

Conversation

@mikehentges
Copy link

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.

@LukeMathWalker
Copy link
Owner

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 extra keys, which is where the real fun begins;
  • Does the JS version of bunyan allow chaining of comparisons? I.e. x == 2 && y == 3?

@mikehentges
Copy link
Author

mikehentges commented Nov 25, 2021 via email

…single field

value - not an arbitrary JS expression like the .js version of bunyan. It will
recursively dive into nested objects in the extras structure. It only attempts to
match the first key that it finds - ignoring other keys with the same name in nested structures.
It also does not allow for matching against array values (including objects in arrays).

2 clean-up items: breaking change in predicate (similar->diff), and a few clippy warnings
@mikehentges mikehentges marked this pull request as ready for review November 26, 2021 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants