casper-network / casper-network/casper-node

Ensure log lines do not exceed limit

Open
#3,286 0 comments 0 reactions 0 assignees View on GitHub
low-priority node
Dominant language
Rust
Stars
399
Forks
224
Avg merge
15h 44m
Merged PRs (30d)
2

Description

Currently, our log message are not limited in length. Some of the log entries contain data fields that can become very large when formatted with `fmt::Debug` formatting (as is usually the case when these are dumped using text for JSON formatters).
An ideal solution would be to filter fields on log messages when writing to logs and substituting a truncated value for all of those that extend a certain length. Given the current implementation and its usage of `tracing_subscriber`'s built-in JSON formatting capabilities, this is a rather large effort, as it involves reimplementing/wrapping/swapping out parts of the setup that were not meant to be easily replaced.

A simpler fix is to restrict line lengths at the writer level. For text-based logging this is straightforward and can be done by limiting line lengths, adding a `...` at the end to indicate missing data.

For JSON, this is not an option, as the result is an unparseable JSON entity. An alternative here could be to substitute in a different JSON record instead that is still well-formed:

```json
json
{"log_message_exceeded_size": "{msg=\"foo\" ..."}
```

Neither dropping the message entirely nor outputting a malformed line are an option, due to the increased burden on downstream consumers of the log file.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.