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

Enhance readability of output logs and errors #1496

Open
yangby-cryptape opened this issue Oct 24, 2023 · 0 comments
Open

Enhance readability of output logs and errors #1496

yangby-cryptape opened this issue Oct 24, 2023 · 0 comments
Labels
enhancement New feature or request principle Coding principle

Comments

@yangby-cryptape
Copy link
Collaborator

yangby-cryptape commented Oct 24, 2023

Proposal

This is a long-term task, and it should be assigned to any specific developers.

I propose several principles for this feature:

  • Please to avoid using Debug format for any data in logs or errors.

    Try use Display format to instead of.

  • For customize structs, please implement Display for it, if it will be output in logs or errors.

  • Please use hex string to display bytes, instead of a Debug format of Vec<u8>.

When writing new codes, please accord these principles.
When you find some bad format when you refactor codes, please fix them with these principles.

Examples for Bad Format

image

[2023-10-27T10:56:58.719999390+08:00 ERROR core_consensus::adapter] [consensus] verify_proof_signature error, number 1, vote: Vote { height: 1, round: 0, vote_type: Precommit, block_hash: b"\x96\xaaC\xc8^\x8e\x05\xa5\x12Xg\xb2g\xa2\x15\x80\x8f\xf8\xbd\xc0\r\x08\xaf\x0b:T\x11\x184\xe9\x8a\xb7" }, vote_hash:b"k\xe9w\xef\x03\xc3\x1a\xb3\xfb\xac\xad@\xe1\xab\xcb\xa9F{6\x01\xa8\xe4Q\x91\x9b\xd1\x1fZ\x01\xf4\xb9\xfb", sig:b"\x93m\xda\xa8\x1d\x14,5\x8f\xf4\x83\xf5\xed\x03=4\x809\x8f\xbb)\xd9OH\xbd\x97\x19#*\xc9I\x04\"c\\q\xe358\x12\x1f,\xf3\x80\x9aXe\xe3\x17;\xa1\xb8Z\x02\xa3 \x1b\x08<\xdf\\\xbe\x1b\\\x85\xa2G\xacb\xd8W\xdc\xaa\x14\xdf\x88r\x1eM\x87\x12\xba5\x85Ez\xeb_\x18\"\\\xc4\xb8\x94Th", signed_voter:[b"\x03\x1d\xdc5!+\x7f\xc7\xfff\x85\xb1}\x91\xf7|\x97%5\xae\xe5\xc7\xaeV\x84\xd3\xe7+\x98o\x08\x83K"]

The above log outputs are terrible.

If the value is Some(0x1234567890...1234567890), it will be better for reading and debugging.

@Flouse Flouse added the enhancement New feature or request label Oct 24, 2023
@yangby-cryptape yangby-cryptape added the principle Coding principle label Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request principle Coding principle
Projects
None yet
Development

No branches or pull requests

2 participants