Move from log to tracing #6809
Description
tracing
(https://docs.rs/tracing/0.1.18/tracing/) is a logging framework that can act as an alternative to log
. By using tracing
it becomes possible to get structured logs and output in different formats. It also supports scoping and dynamic log filtering. Rust compiler also recently moved from log
to tracing
. rust-lang/rust#74726
The goal of this issue would be to convert the code base from majority log
-based, to majority tracing
-based. The interface is compatible, so once the conversion is done, we can then gradually add additional structural data into the logging.
From my look we can convert all use cases of log
to tracing
drop-in, with only one exception:
frame_support::debug
. The issue with this is that it crosses the wasm boundary and it already exports a wasm API that is slightlylog
-specific. So I think we keep it aslog
for now.
There will also be dependency crates using log
. As a result we need the log
compatibility layer for tracing
.
- The current default logger of
log
is changed to betracing_log::LogTracer
. This converts all log records to tracing events, and make it available to tracing subscribers. - Then, we collect all logs in tracing subscribers and handle the output with combination of
sp_tracing::ProfilingSubscriber
andtracing_subscriber::FmtSubscriber
.