-
Notifications
You must be signed in to change notification settings - Fork 732
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
Inconsistent behaviour in tracing_subscriber wrt tracing_log #3053
Comments
Do you have the |
Yes, I have it turned on for both code examples above. It is surprising it doesn't init it also in the first code example though. |
The first example initiates your own subscriber using the |
Aha, perhaps that should be better documented somewhere (tracing is a non-trivial ecosystem, much more complex than log). I don't know where this would be best documented though. Perhaps some overview "theory of operation" style docs would be a suitable place for it. |
Yeah, I know, especially initiating a logger is confusing for a lot of people. Maybe we should add a section in here about the initiation of |
Hm, I like what some crates like clap, bpaf and winnow are doing: having special "chapters" (modules only included for docs.rs) that contain more of reference/tutorial style documentation (as the module level doc). An mdbook could also be an even better (but more work) location for that. Another way to look at it: are there too many different ways to do the same thing today? Perhaps it should be documented as "this is the full way of setting up loggers" and "this is the shortcut for the common case" (and reduce the number of possible shortcut approaches). That is obviously a breaking change, so not to be taken lightly, but there is something to be said for simplifying the API. Yet another perspective: For everything except the most simplest of crates the majority of users will not have time to read all the docs and get a full understanding of how it works. As a user I generally just want to get whatever I'm trying to do done and the move on with my own project. This applies even more so for "helpers" (like logging, serialisation, command line argument parsing etc) that are necessary but not part of my main objective. That means the the top level documentation (and any clap/winnow style chapters or mdbooks) for the crate in question is critical. That is where I will find out how to use the crate, take the examples and adapt it to what I need. In conclusion: adding a note where you suggest is not a bad idea, but I would have missed it anyway, since I wasn't even looking at the registry until tokio-console forced me to (before I used the non-registry approach based on the top level docs of tracing/tracing-subscriber) |
That's actually a nice idea, I like what clap is doing there. I also find myself often looking at the tracing examples, so maybe we could "convert" them somehow to written chapters. |
Bug Report
Version
(Some of that duplication is due to using cargo workspace hack I believe.)
Platform
Linux athena 6.10.3-zen1-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Sun, 04 Aug 2024 05:11:13 +0000 x86_64 GNU/Linux
Crates
tracing-subscriber and/or tracing-log
Description
The behaviour between tracing_subscriber and tracing_log is inconsistent with regards to if you need both or just the former:
Take the following code:
Here the
tracing_log
call is required to get events from thelog
crate to appear. However if I rewrite it to usetracing_subscriber::registry()
instead, it suddenly causes a panic and thetracing_log
call must be removed. This seems very inconsistent:As far as I understood the documentation the two above ways of using tracing_subscriber should be equivalent, but apparently they are not. This might be a documentation issue, and the docs needs to explain the difference (I came across this when rewriting to the second form to be able to add support for tokio-console as well).
Either both should work the same, or the documentation should be clear on why they don't work the same.
The text was updated successfully, but these errors were encountered: