I want to gather some feedback before putting more work into this PR.
There is a standard trait implementation of SubscriberInitExt. I cannot use a builder pattern for persisting the flag to signal whether a global logger should be initialized or not because I cannot introduce any trait fields.
My workaround is to add a feature gated parameter to init and try_init to then conditionally set the global logger.
I am not sure if you are OK with having feature gated parameters and with such a breaking change.
Regarding the update of the init methods I feel it is a good decision to give (and also enforce) more fine grained control during runtime. I have seen bugs in other repos where people were pulling in tracing-subscriber without being aware of the consequences (of having a global logger set) when tracing-log is enabled by default. Normally you would only have tracing-subscriber down the stream when letting another lib manage your tracing init logic. For such scenarios it makes sense to throw compile time errors in case that specific lib does not support the feature gated with_logger parameter. Imho that is better than unexpected behavior in terms of silently tracing logs.
Motivation
Solves https://github.com/tokio-rs/tracing/issues/3074
Solution
I want to gather some feedback before putting more work into this PR.
There is a standard trait implementation of
SubscriberInitExt
. I cannot use a builder pattern for persisting the flag to signal whether a global logger should be initialized or not because I cannot introduce any trait fields.My workaround is to add a feature gated parameter to
init
andtry_init
to then conditionally set the global logger.I am not sure if you are OK with having feature gated parameters and with such a breaking change.
Regarding the update of the init methods I feel it is a good decision to give (and also enforce) more fine grained control during runtime. I have seen bugs in other repos where people were pulling in
tracing-subscriber
without being aware of the consequences (of having a global logger set) whentracing-log
is enabled by default. Normally you would only havetracing-subscriber
down the stream when letting another lib manage your tracing init logic. For such scenarios it makes sense to throw compile time errors in case that specific lib does not support the feature gatedwith_logger
parameter. Imho that is better than unexpected behavior in terms of silently tracing logs.Another alternative could be a new method which then does not prevent existing users from thinking more about the impact of the default behavior
fn try_init_with(self, set_logger: bool)