Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Move from log to tracing #6809

Closed
Closed
@sorpaas

Description

@sorpaas

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 slightly log-specific. So I think we keep it as log 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 be tracing_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 and tracing_subscriber::FmtSubscriber.

cc @mattrutherford

Metadata

Metadata

Assignees

Labels

I7-refactorCode needs refactoring.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions