nervosnetwork / fiber

19 stars 10 forks source link

Consider use a more advanced tracing library (e.g. tokio-rs/tracing) for logs #95

Closed contrun closed 4 months ago

contrun commented 4 months ago

We current use https://docs.rs/log/latest/log/ for logs. As more and more debug logs are accumulating, this can quickly become unwieldy. The major pain points for me is

  1. No structured logging support. There are currently many logs like

https://github.com/nervosnetwork/cfn-node/blob/11f710bafc809af779441daf1eb73b1b603e185c/src/ckb/channel.rs#L1956-L1959

scattered around the code base, with tokio-rs/tracing, we can easily convert the above statement to

        debug!(
            commitment_number = commitment_number,
            commitment_point = commitment_point,
            "Obtained commitment point for commitment number",
        );

The major benefit of above statement for now is enhanced search-ability while debugging. Structured logging may have other benefits in the future.

  1. No context. No application level calling stacks. Here are two examples why these things might be useful.