tokio-rs / tracing

Application level tracing for Rust.
https://tracing.rs
MIT License
5.15k stars 673 forks source link

parse only comma-less field part as field #2936

Open Voker57 opened 2 months ago

Voker57 commented 2 months ago

Motivation

Multiple field parsing is broken: even if proper string is passed to the parser, commas are parsed as part of the field This partially fixes #2935

Solution

Pass only 1st capture group to the field parser, instead of the whole string

Voker57 commented 2 months ago

This looks good to me. Would you mind adding a test for a filter expression that would previously have been parsed incorrectly? Thanks!

I fixed the test, however it will fail both with and without my modification because commas are parsed earlier as delimiters for multiple filters. I'm not sure how to fix this, honestly the whole parsing system is a mess and should be rewritten using a parser combinator. For my usage I changed the filter delimiter to +, can prepare a patch if you don't mind compatibility breaking in such a way. Also, I replaced EnvFilter::new with try_new to make errors fail test, this should be done for all tests and maybe you'll discover many other interesting things.