pub struct LogGuard { /* private fields */ }Expand description
Owns the private logging worker installed by init.
Keep this value alive for as long as logging should remain active.
Dropping it rejects log calls that begin afterwards. A record already being emitted concurrently may complete or be discarded — the guard does not join the worker thread, the same trade the lossy writer already makes on a full queue.
The final flush is attempted, not promised. The drop asks [WorkerGuard] to
shut the worker down, which enqueues a shutdown message on the same bounded
channel the records use — waiting at most 100ms — and then waits at most one
second for the worker’s acknowledgement, sent only after it has flushed
everything already queued. So under normal conditions queued records do reach
the file, but a file writer stalled long enough to keep that channel full
makes the drop give up and return with records still queued. On that path
tracing-appender also prints one line to the process’s stdout, which this
crate cannot suppress. The worker still terminates and flushes on its own
afterwards (see this type’s Drop), just with nothing waiting for it.
It is deliberately not stored in a static because Rust does not drop static values at process exit, which would make even that attempt impossible.