Function trace_tools::subscriber::collect_logs
source · [−]pub fn collect_logs() -> Result<(), SetLoggerError>
Expand description
Initialises a tracing_log::LogTracer
that converts any incoming log
records into tracing
events,
allowing subscribers to interact with log records.
This is necessary to perform logging through the log
crate whilst also setting the global logger to a
tracing::Subscriber
implementation.
Errors
- Returns an
Error
if this function has failed to set the global logger.
Notes
- This should only be called once. Any subsequent calls will fail, since the global logger can only be set once in a program’s lifespan.
- If the global logger has already been set (by the
log
crate, for example), this will fail.