MiSawa / xq

Pure rust implementation of jq
MIT License
318 stars 18 forks source link

feat(tracing): move to tracing library #160

Closed Larandar closed 1 year ago

Larandar commented 1 year ago

This is IMO the first step toward #119; the ability to have structured logs will for sure be useful for it. As a bonus, I updated clap to 4.0 and fixed clippy pestering about variables in format! directly.

MiSawa commented 1 year ago

Thank you for the PR.

This is IMO the first step toward https://github.com/MiSawa/xq/issues/119; the ability to have structured logs will for sure be useful for it.

Unfortunately it's not really related IMO; What #119 require is to propagate the positional information of the jq source code to AST (and perhaps even to the compiled op codes) so that when we return Err we can return a reasonable position along with it. Then we can use that positional information to show a prettier error message using some library println!("{}", some_library_that_generates_fancy_diagnostic_message(message, source_code, position))

Larandar commented 1 year ago

Totally, and I aggree there is more to do on the AST side, but tracing allow for more complex formating of errors and logs than the log crate.

In particular tracing allow for structured logs, and subscribers (the log formatters) can filter and use those structured values. The only structured log I set up is the first log of main() at the moment but more could be added (in particular in the AST)

It's up to you, and if you wish to cherry pick only the chores feel free to :)

MiSawa commented 1 year ago

Thanks, let me cherry-pick 2 commits from this MR!