Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete rewrite to support arbitrary logic expressions #15

Open
dvtomas opened this issue Sep 27, 2018 · 9 comments
Open

Complete rewrite to support arbitrary logic expressions #15

dvtomas opened this issue Sep 27, 2018 · 9 comments

Comments

@dvtomas
Copy link

dvtomas commented Sep 27, 2018

Hi, folks,
what do you think of this?

dvtomas@f0376dc

I know it's big, I got carried away, the filtering logic I need is different, so I generalized the original quite a bit...

I think the performance should be roughly the same as the original, but the possibilities to use it in creative ways and extend it (@przygienda , I see you are just adding a regex support, that should be an easy FilterSpec addition) are IMO just so much greater..

@przygienda
Copy link
Collaborator

przygienda commented Sep 29, 2018 via email

@dvtomas
Copy link
Author

dvtomas commented Sep 30, 2018

I guess we can have the cake and eat it too. The new design is quite flexible in ways it can be extended to support new functionality (say regex, or your HashSet).

I guess we could just add a new variant here: https://github.com/dvtomas/kvfilter/blob/7a1f21329b305c7c4015f68ecf2ee5a284c3c579/src/lib.rs#L56

Something like

MatchAllValues {key: String, values: HashSet<String>}

We get the performance of the original for your use case plus the flexibility of the new design. What do you think?

Out of curiosity, can you give me an example of your typical logging configuration? I'm a little bit surprised that you have a lot of key-values that configure the logging. The way I use logging is that usually I have just a LevelFilter set to Info, and only when a problem occurs, I temporarily enable debug or trace in the particular subsystem I'm interested in, thats usually one or two KV's. For this scenario I guess Vec would be faster than HashSet, it carries less overhead, no need to compute hash etc.. So I'm interested about the logging patterns others use, I'd be very grateful if you could give me an example of yours..

@przygienda
Copy link
Collaborator

przygienda commented Sep 30, 2018 via email

@dvtomas
Copy link
Author

dvtomas commented Sep 30, 2018

All right, I think I can implement MatchAllValues with the type signature sketched above. Just to make sure: The proposed behavior is that a given key must have all the values in the HashSet, is that correct? If I give an example:

log!(log, "Message"; "key" => "value1", "key" => "value2")
would be accepted by
MatchAllValues {key: "key", values: ["value1", "value2"]] }
but rejected by
MatchAllValues {key: "key", values: ["value1", "value3"]] }
is that correct?

As for the regex, how would that work? Is something like MatchValueRegex {key: String, value: RegEx} what you want?

I'll be having vacation most of the next week, but I'll try to implement it as soon as i get to it.

@dvtomas
Copy link
Author

dvtomas commented Oct 2, 2018

@przygienda, please confirm I got the specification of what you need right. I'll implement it most probably during the weekend.

@dvtomas
Copy link
Author

dvtomas commented Oct 5, 2018

Implemented, see the relevant PR

@dvtomas
Copy link
Author

dvtomas commented Oct 6, 2018

The CI fails on Rust 1.20, the serde_regex crate doesn't compile because of match ergonomics. Rust 1.20 is over a year old now, the question is if there's any reason to support it?

@przygienda
Copy link
Collaborator

przygienda commented Oct 6, 2018 via email

@dvtomas
Copy link
Author

dvtomas commented Oct 6, 2018

OK, I've submitted an issue and a PR tailhook/serde-regex#2 to the serde_regex crate. Hopefully the author will publish the fixed version soon and we'll be able to go on.

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

No branches or pull requests

2 participants