Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No longer use the log crate in the light client #1560

Merged
merged 14 commits into from
Jan 8, 2024

Conversation

tomaka
Copy link
Contributor

@tomaka tomaka commented Jan 8, 2024

Close #756

This PR removes usage of the log crate from the light client and instead adds a new function on the PlatformRef trait.
The DefaultPlatform uses the log crate, which means that the behavior actually doesn't change compared to before.

This PR is however a breaking change as it modifies the PlatformRef trait. See the changes to light-base/src/platform/default.rs to see how to migrate. cc @skunert @ermalkaleci @lexnv as a heads up.

I'm doing this for two reasons:

  • Having key-values logging is better than just a plain message for a variety of reasons, notably being able to parse log messages more easily for indexing. The kv_unstable feature of the log crate has been there for, I don't know, years? and still is nowhere near stabilization.
  • In case where there are multiple smoldot light clients running in parallel in the same process, which is useful in testing situations, it is useful to be able to add a prefix before the target of every log message. This is simply impossible to do with the log crate (there's a reason why global variables are considered as a bad thing).

An alternative could have been to use the tracing crate, but I generally really dislike the tracing crate due to being over-engineered and confusing. It shouldn't take ten of hours of learning in order to print a log message.

As part of this refactoring, I've rewritten all the log messages. Since logs are mostly for bug reports, this should be completely fine. I think and I hope that nobody was parsing log message programatically.

@tomaka tomaka added this pull request to the merge queue Jan 8, 2024
Merged via the queue into smol-dot:main with commit 7c65395 Jan 8, 2024
23 checks passed
@tomaka tomaka deleted the light-client-log branch January 8, 2024 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No longer use the log crate in light-base
1 participant