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

Move from log to tracing #6809

Closed
sorpaas opened this issue Aug 4, 2020 · 1 comment
Closed

Move from log to tracing #6809

sorpaas opened this issue Aug 4, 2020 · 1 comment
Assignees
Labels
I7-refactor Code needs refactoring.

Comments

@sorpaas
Copy link
Member

sorpaas commented Aug 4, 2020

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

@sorpaas sorpaas added the I7-refactor Code needs refactoring. label Aug 4, 2020
@sorpaas sorpaas self-assigned this Aug 4, 2020
@mattrutherford
Copy link
Contributor

I'm wondering if it's possible to use a single subscriber, possibly the FmtSubscriber, with an extra Layer (https://docs.rs/tracing-subscriber/0.2.10/tracing_subscriber/layer/trait.Layer.html) to do the time profiling and other things we need. I think it should also be feasible to dynamically filter which Spans we wish to profile and which we do not, so we don't incur the extra cost of that where not required.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
I7-refactor Code needs refactoring.
Projects
None yet
Development

No branches or pull requests

3 participants