Closed Flakebi closed 3 years ago
6e8e5b3b14aec1d6e422b6de65af1e96b235b582 Replace slog
with tracing
Uhm, why was this change made if I may ask?
It looks like tracing
is the way forward as it’s adopted by more crates and provides similar structured logging as slog
. Incidentally, making the switch reduced the size of the code base noticably, which was surprising for me.
It's mostly that I find passing around a logger much easier to think about than working with globals. I switched to slog
because I have multiple connections to TeamSpeak open at the same time. Each connection has it's own slog
logger with the name of the connection attached to make logs readable.
I have no idea how I would achieve the same with tracing
currently. Do you have any advice?
The global instance is much easier I think. Having to create a logger, passing it around and dealing with ownership for logging is pretty annoying in my opinion. (And also it's better to go with the community to reduce crate overhead and get better "support".)
The thread locality makes it difficult for me to understand how to link spans to sections of code for me. It seems like each thread has one span at a time instead of each piece of code having one logger to me but I might be wrong.
I see what you mean, the same thing bugged me when doing the transition. The implicit logger works well for functional-style programming but not so much for long-living objects.
It’s still possible to explicitly pass around a logger. Span::current()
gives the current logger, then use let _span = my_span.enter();
or log!(parent: &my_span, …)
to log. I use that in the audio handling.
That sounds nicer, I might give that a try, thanks!
self_cell was updated to 0.10 in 8436d5ff9ce78793519f5a9ec16ed9bef0ba94e5 due to soundness bugs (see #27 for more info).
Huh, that's kind of stuff why I fear writing these low level things myself.
This issue is used to announce breaking changes when they are pushed.
cc @0xpr03