-
Notifications
You must be signed in to change notification settings - Fork 92
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
Add --debug
option for logging and backtraces
#371
Conversation
Add `env_logger` to be able to print the logs that our libraries already generate. Add some logging to the application code. We'll probably want more log messages, and we might want to upgrade some of them from trace to debug. Add a `--debug` flag that automatically enables `env_logger` as well as backtraces for `anyhow` and panics. ```console $ xh --debug : [2024-06-05T13:54:40Z DEBUG xh] xh 0.22.0 -native-tls +rustls [2024-06-05T13:54:40Z DEBUG xh] Cli { httpie_compat_mode: false, [...] } [2024-06-05T13:54:40Z DEBUG xh] Complete URL: http://localhost/ [2024-06-05T13:54:40Z DEBUG xh] HTTP method: GET [2024-06-05T13:54:40Z DEBUG reqwest::connect] starting new connection: http://localhost/ [2024-06-05T13:54:40Z DEBUG hyper_util::client::legacy::connect::dns] resolving host="localhost" [...] xh: error: error sending request for url (http://localhost/) Caused by: 0: client error (Connect) 1: tcp connect error: Connection refused (os error 111) 2: Connection refused (os error 111) Stack backtrace: 0: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/anyhow-1.0.82/src/error.rs:565:25 [...] ``` We could ask users to post `--debug` output when reporting bugs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Sorry for taking so long to review this
The old way makes more sense to me but this is what Rust itself does.
Rust started linting this as dead_code.
How do you feel about logging a timestamp relative to startup?
Alternatively:
Seems better than including the date and everything but I'm on the fence about whether it's worth showing by default. And which style to use. |
Nice, the relative timestamp version looks much better! I think we can enable it by default in debug mode. Regarding the style to use for the timestamp, the first version seems easier to scan, but I don't have any strong opinions. Would the latter work better for higher timestamp precision? |
|
Timeout for the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved 🎉
Timeout for the deflate test on ARM: https://github.com/ducaale/xh/actions/runs/9604382549/job/26489748373
If that happens again we should look into it. (It's probably not a second xz, but...)
Haha, tests on ARM tend to hang more often, and it might be related to rust-cross
. Either way, I'm patiently waiting for the day GitHub's ARM runner becomes generally available.
Add
env_logger
to be able to print the logs that our libraries already generate.Add some logging to the application code. We'll probably want more log messages, and we might want to upgrade some of them from trace to debug.
Add a
--debug
flag that automatically enablesenv_logger
as well as backtraces foranyhow
and panics.We could ask users to post
--debug
output when reporting bugs.