I have tracing initialization code as follows.
pub fn make_dispatch() -> (Dispatch, WorkerGuard) {
let file_appender;
if let Ok(tracefile) = env::var("WISK_TRACEFILE") {
file_appender = tracing_appender::rolling::never("", tracefile)
} else {
file_appender = tracing_appender::rolling::never("", "/dev/null")
}
let (non_blocking, guard) = tracing_appender::non_blocking(file_appender);
let subscriber = FmtSubscriber::builder()
.with_max_level(Level::TRACE)
.with_writer(non_blocking)
.finish();
(Dispatch::new(subscriber), guard)
}
thread_local!(static MY_DISPATCH: (Dispatch, WorkerGuard) = make_dispatch());
Which is then used
MY_DISPATCH.with(|(my_dispatch, _guard)| { ........... });
But in this case, I don't actually want to initialized a thread_local instance of my_dispatch.
I only want to check if the value is initialized or not.
Something like
if MY_DISPATCH.initialized() {
// do somethig
} else {
// something else
}
How do I do that?
Also I don't see ay example of MY_DISPATCH.try_with. Any pointers?