forest
forest copied to clipboard
use `tracing`'s structured logging
Before: https://github.com/ChainSafe/forest/blob/9e3ed095a32d14a293ce7ed7b52b48d74d3b67b3/src/chain/store/chain_store.rs#L221 After:
info!(epoch = %ts.epoch(), key = %ts.key(), "new heaviest tipset");
Before: https://github.com/ChainSafe/forest/blob/9e3ed095a32d14a293ce7ed7b52b48d74d3b67b3/src/rpc/channel.rs#L360 After:
tracing::error!(?e, "Failed to serialize channel message");
Plan
- refactor all
tracingcallsites- Could this be automated with
synsert?
- Could this be automated with
- educate team on
std::error::Errorandanyhow::Error's design- (structured) logging principles
- Each
infostring or above should be unique and descriptive - Fields should be structured so that we can run metrics on them
- Logging vs end-user messages
- Each
- [hard] write CI
Motivation
Either... or all error messages should use the
?eor a variant of that. If we do the latter, it should be enforced in CI.
Originally posted by @LesnyRumcajs in https://github.com/ChainSafe/forest/issues/4128#issuecomment-2036753097