-
Notifications
You must be signed in to change notification settings - Fork 24
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 DebugLevel, TraceLevel, OffLevel #122
Comments
So if I'm understanding correctly, this is the only documented use case for this feature, right? Before anything else, thank you for including a use case! With a prototype where you want all of the gory details, you can change the levels on the log messages, or change the log level. Understandable to want to change it in as few places as possible. The workaround for this situation is to pass in the log level flags. I'm assuming the concern there is in always remember and type out the flags? A cargo alias could help with this ( I suspect I'm missing something about your workflow because I'm having a hard time putting myself in your shoes for wanting to develop this way. For myself, in developing an application, I write at in a production style from the beginning. I can maybe see it more for a prototype but I feel like I could quickly get overwhelmed with the output, masking what I'm looking for on regular runs. This also doesn't scale to new feature development as I would assume you wouldn't want to change the default down to debug and then bring it back up again. As for feature prototyping, again, this makes more sense but with an existing application it would be even more overwhelming to see everything logged on every run. |
Yeah, but then Debug / Trace logs really are something that you'd usually only need for development purposes, so it's kind of a tautology that these would be only used while developing / prototyping / bug bashing. My comment about security was alluding to config options which allow self signed certs. You definitely don't want that on in prod, but you also definitely want to be able to use it when you don't want the overhead of doing the full TLS cert thing for dev. This feels similar (but without any security impact).
I suspect that the part you're missing is that often command line projects are a useful tool as a discovery / diagnosis mechanism. Their purpose is not to live forever in a production state, but are instead used as throwaway code, which serves as:
Often the ability to discover the internals of how some crate works is only surfaced through logging / tracing. I have many throwaway clis for various things like this. There's also the power of defaults. I can hit This is my general workflow cargo new --bin foo
code foo
cargo add clap clap-verbosity-flag --features clap/derive
cargo add tracing tracing-subscriber
cargo add some-other-lib
Now my options are:
Taking a drink from the firehose isn't something I do for very long either, but it's something that often I want to do before winding back the information that is coming my way (e.g. turning of things in hyper / h2 / etc. on my tracing config). Some concrete examples:
All of these were cases of use debug / trace level for some time, but in the end leave it as some higher level. |
So to put a different way, this is less for development of a production application but true prototypes / exploratory programming.
I always overlook these as I don't "invest" in the use of LSPs. The cases you listed seem reasonable. I'm ok with this moving forward. Thank you for taking the time to help me understand! If nothing else, something that came from this is me better understanding how people are using my crates so I can make better decisions in the future! |
Yeah, most of my Rust programming is non-production related, so the lens I look at these things has quite a different tint.
Thanks for making all the crates and investing the time to understand use cases that are a bit different from the norm. I appreciate your time in both. I'll do up a PR soon. |
This adds `OffLevel`, `DebugLevel`, and `TraceLevel` to the list of log levels that can be set as the default log level for the logger. A new example, `log_level.rs`, demonstrates how to set the default log level for Verbosity to something other than the default. It can be run with `cargo run --example=log_level [default level] [flags]`. E.g.,: `cargo run --example=log_level off -vvvv` will set the default log level to `OffLevel` and then apply the verbosity flags to set the log level to `Debug`. Fixes: clap-rs#122
This adds `OffLevel`, `DebugLevel`, and `TraceLevel` to the list of log levels that can be set as the default log level for the logger. Fixes: clap-rs#122
Per request on #95 (which seems stalled), I'm creating another issue about DebugLevel, TraceLevel, OffLevel.
In #80, the rationale for not including these was:
I responded to #80 after it was closed, but my response got no response. Here's a simplified version of that (and a longer one at the end.
Yes, I believe that there are sound reasons to re-think the above assumptions due to the following counterexamples:
For a specific data point on this. I've used this in 8 different CLIs and this problem has come up in each of them. Often it's things like the data that I care about during prototyping / development is at DEBUG/TRACE level (e.g. the exact details of some web requests)
Given that we both seem to be coming from the perspective of whether this is reasonable, If after reading the above you still feel like this should not be part of the library, I think it would be helpful to share a bit more information about the problems you see with this being a normal part of the lib.
Previous message in response to #80
Hey, @epage I saw this got a little heated above, and while I don't want to stir that up again, I'd like to throw a use case into the mix. If you'd prefer me to open another issue rather than continuing this one, or comment in #95 instead, I'm happy to do that.
TL;DR: This got a little long while writing, but I'm not sure what to cut out. Apologies in advance for the long read:
During prototyping a cli app, it would be nice and let me fall into the pit of success to have a default level of debug available to me. This would make it easy for me to have http requests show up in my logs and various things like that. Once I'm done prototyping this can certainly be switched back to the default.
If I'm writing a few different CLIs for various things, this additional boilerplate code to set a default that is not available seems heavy. It ends up getting duplicated across a few places, and it's effectively throw away code that I want to delete when it's no longer in use. But I also want the ability to turn that back on if needs be.
So given these concerns:
I come to the same conclusion that including the other levels is the right thing based on those assumptions.
Right now there are 3 similarly named crates. The changes aren't documented, but I think they're:
As a consumer looking to simplify a verbosity flag in a cli app, this is a confusing place to be in. I want both of those extra features, but I also want to generally use software which I know will get regularly maintained rather than being a single issue fork.
I think much of what I wrote seems to align with the arguments that @SUPERCILEX was making here.
I think this way to define how an API should choose features has some problems, as it overindexes on what is "correct". I don't think there is a correct universally accepted log level that's most useful for all use cases. For some use cases, that level is DEBUG, for some it's ERROR. I don't particularly know any specific use cases where logging at a TRACE level by default makes sense, but I can see that it's reasonable to want that.
Here, there seems like there's a reasonable default (ERROR) that aligns with a default that's used in many logging frameworks, and that works well enough, but not providing the other levels seems just odd and the sort of thing that only has downside.
Perhaps there's a specific use case that you're thinking of that's unstated here where defaulting the verbosity flag level to DEBUG / TRACE would cause known issues? I wonder if you could expand on those a bit more, because those seem like the more theoretical problems to me (but it's likely I don't have the same perspective as yours, so I'm seeking to understand yours a bit more here too).
The text was updated successfully, but these errors were encountered: