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

Logging: use terminal format with full hashes #1770

Merged
merged 3 commits into from
Jan 31, 2024

Conversation

BedrockSquirrel
Copy link
Collaborator

@BedrockSquirrel BedrockSquirrel commented Jan 31, 2024

Why this change is needed

In recent PR I tried to fix the shortened hashes in our logs, to make them searchable in etherscan etc. But actually what I did had no effect on testnet logs and put our sim logs into a different, machine readable format.

We wanted to use the terminal format everywhere but with full hashes.

What changes were made as part of this PR

  • Create a Ten log Format that we have full control over
  • duplicate the utility classes to make this match geth Terminal format

In this screenshot the new format is above and the old format below. You can see the L1 transaction successful message now has searchable hashes:

image

PR checks pre-merging

Please indicate below by ticking the checkbox that you have read and performed the required
PR checks

  • PR checks reviewed and performed

Copy link

coderabbitai bot commented Jan 31, 2024

Walkthrough

The update introduces a new custom log formatting functionality, TenLogFormat, across several components of the project. This change shifts the logging approach from using generic formats provided by gethlog to a more tailored TenLogFormat. The modifications are applied in core logging setup functions and specific tools such as faucet and walletextension, ensuring consistent log output formatting throughout the project.

Changes

Files Change Summary
go/common/log/log.go, .../common/testlog/testlog.go Replaced gethlog formats with TenLogFormat for initializing loggers and log handler setup.
go/common/log/logformat.go Added custom log formatting functionality for the Ten logger, including new logic and modifications.
tools/faucet/faucet.go, .../walletextension/common.go Updated to use tenlog.TenLogFormat() for logging and added the tenlog package import.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b69bb7f and d942bd4.
Files selected for processing (5)
  • go/common/log/log.go (1 hunks)
  • go/common/log/logformat.go (1 hunks)
  • integration/common/testlog/testlog.go (1 hunks)
  • tools/faucet/faucet/faucet.go (2 hunks)
  • tools/walletextension/common/common.go (2 hunks)
Additional comments: 8
integration/common/testlog/testlog.go (1)
  • 48-48: The change from gethlog.LogfmtFormat() to log.TenLogFormat() in the Setup function aligns with the PR's objective to enhance log readability by adopting a terminal format that includes full transaction hashes. This modification ensures that logs are now more informative and user-friendly, particularly for tracking transactions on blockchain explorers.
go/common/log/log.go (2)
  • 60-60: The replacement of gethlog.TerminalFormat with TenLogFormat for the StreamHandler in the New function is a crucial part of implementing the custom "Ten log Format." This change ensures that logs output to stdout will use the new format, enhancing readability and information richness.
  • 62-62: The modification to use TenLogFormat in the FileHandler within the New function is consistent with the PR's goal to improve log formatting across the project. This ensures that logs written to files will also benefit from the enhanced format, making them more useful for debugging and analysis.
tools/walletextension/common/common.go (2)
  • 11-11: The addition of the log package from github.com/ten-protocol/go-ten/go/common is necessary to access the TenLogFormat function. This change is part of the broader effort to standardize log formatting across the project.
  • 96-96: Replacing gethlog.TerminalFormat with log.TenLogFormat in the NewFileLogger function ensures that the wallet extension's logs will now use the custom "Ten log Format." This modification aligns with the PR's objectives to enhance log readability and utility.
tools/faucet/faucet/faucet.go (2)
  • 16-16: The import of the tenlog package is essential for utilizing the TenLogFormat function within the faucet tool. This change is part of the effort to adopt the new log format across different components of the project.
  • 41-41: Initializing the logger with tenlog.TenLogFormat() in the NewFaucet function ensures that the faucet's logs will adhere to the new, more informative and readable log format. This is in line with the PR's goal to improve the logging experience.
go/common/log/logformat.go (1)
  • 1-324: The introduction of the logformat.go file and the TenLogFormat function represents a significant enhancement to the project's logging system. This custom log format is designed to replicate the Geth terminal format's appearance and functionality, including full transaction hashes, which improves log readability and utility. The implementation details, such as the handling of various data types and the alignment of log messages, are well thought out and align with the PR's objectives. However, it's important to ensure that this new format is thoroughly tested, especially in edge cases where log messages might contain unusual characters or extremely long values that could affect the formatting.

Copy link
Collaborator

@tudor-malene tudor-malene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between d942bd4 and 52677ae.
Files selected for processing (1)
  • go/common/log/logformat.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • go/common/log/logformat.go

@BedrockSquirrel BedrockSquirrel merged commit 22b397d into main Jan 31, 2024
2 checks passed
@BedrockSquirrel BedrockSquirrel deleted the matt/fix-log-format branch January 31, 2024 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants