ChainSafe / ChainSafe/forest

use `tracing`'s structured logging

Open
#4,143 0 comments 0 reactions 0 assignees View on GitHub
Priority: 4 - Low Type: Enhancement
Dominant language
Rust
Stars
697
Forks
200
Avg merge
1d 5h
Merged PRs (30d)
65

Description

Before:
https://github.com/ChainSafe/forest/blob/9e3ed095a32d14a293ce7ed7b52b48d74d3b67b3/src/chain/store/chain_store.rs#L221
After:
```rust
info!(epoch = %ts.epoch(), key = %ts.key(), "new heaviest tipset");
```

Before:
https://github.com/ChainSafe/forest/blob/9e3ed095a32d14a293ce7ed7b52b48d74d3b67b3/src/rpc/channel.rs#L360
After:
```rust
tracing::error!(?e, "Failed to serialize channel message");
```

# Plan
- refactor all `tracing` callsites
- Could this be automated with `synsert`?
- educate team on
- `std::error::Error` and `anyhow::Error`'s design
- (structured) logging principles
- Each `info` string or above should be unique and descriptive
- Fields should be structured so that we can run metrics on them
- Logging vs end-user messages
- [hard] write CI

# Motivation
> Either... or all error messages should use the `?e` or 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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.