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

fix: ensure log crate output is shown with tracing #2477

Merged
merged 2 commits into from
Sep 25, 2024

Conversation

glihm
Copy link
Collaborator

@glihm glihm commented Sep 25, 2024

Summary by CodeRabbit

  • New Features
    • Introduced a new logging framework to enhance logging capabilities across the application.
  • Improvements
    • Updated logging configuration to reduce verbosity for specific components, improving log clarity.
    • Simplified logging setup process for better maintainability.
  • Bug Fixes
    • Resolved issues related to logging initialization to ensure robust logging behavior.

@glihm glihm requested a review from kariy September 25, 2024 14:21
Copy link

coderabbitai bot commented Sep 25, 2024

Walkthrough

Ohayo, sensei! The recent changes involve updates to the Cargo.toml file, enhancing dependency management by upgrading the tracing crate and introducing tracing-log. The logging configurations in the bin/saya, bin/sozo, and bin/katana projects have been refined to adjust log verbosity and integrate the LogTracer, improving the overall logging infrastructure. These modifications collectively aim to streamline logging practices across the projects.

Changes

Files Change Summary
Cargo.toml Updated tracing from 0.1.34 to 0.1.38 with features and added tracing-log as a new dependency. Adjusted workspace declarations for tracing-log in bin/sozo, bin/saya, and bin/katana.
bin/saya/src/args/mod.rs Modified init_logging method to change logging filter and added LogTracer::init() for logging initialization.
bin/sozo/src/args.rs Updated init_logging to include salsa=off in logging configuration and transitioned to using FmtSubscriber.
bin/katana/src/cli/node.rs Added LogTracer::init() to initialize logging infrastructure in NodeArgs.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SayaArgs
    participant SozoArgs
    participant NodeArgs
    participant LogTracer

    User->>SayaArgs: Initialize logging
    SayaArgs->>LogTracer: LogTracer::init()
    LogTracer-->>SayaArgs: Logging initialized
    SayaArgs->>SayaArgs: Set logging filter

    User->>SozoArgs: Initialize logging
    SozoArgs->>LogTracer: LogTracer::init()
    LogTracer-->>SozoArgs: Logging initialized
    SozoArgs->>SozoArgs: Set logging filter

    User->>NodeArgs: Initialize logging
    NodeArgs->>LogTracer: LogTracer::init()
    LogTracer-->>NodeArgs: Logging initialized
    NodeArgs->>NodeArgs: Set logging filter
Loading

🪧 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>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 testing code 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
bin/sozo/src/args.rs (1)

55-64: Ohayo, sensei! Great improvements to logging initialization!

The changes to the init_logging method are well-thought-out and improve the overall logging configuration. Here's a breakdown of the improvements:

  1. The addition of salsa=off to the default log filter is a nice touch.
  2. Using LogTracer::init() ensures proper setup of logging before creating the subscriber.
  3. The new implementation is more robust, using environment variables with a fallback to the default filter.
  4. The code is more concise and easier to read with the use of FmtSubscriber.

Consider extracting the tracing_subscriber::EnvFilter::try_from_default_env() logic into a separate function for better readability. Here's a suggestion:

fn get_env_filter() -> tracing_subscriber::EnvFilter {
    tracing_subscriber::EnvFilter::try_from_default_env()
        .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new(DEFAULT_LOG_FILTER))
}

// Then in init_logging:
let subscriber = FmtSubscriber::builder()
    .with_env_filter(get_env_filter())
    .finish();

This change would make the init_logging method even more concise and easier to understand.

bin/saya/src/args/mod.rs (1)

78-80: Excellent adjustments to the logging configuration, sensei!

The changes in the init_logging method are well thought out:

  1. Modifying the default log filter string to disable blockchain and provider logging will help reduce noise in the logs, allowing us to focus on more relevant information.

  2. The addition of LogTracer::init()?; is crucial for integrating log crate output with tracing. This ensures that all logs, regardless of their source, are processed uniformly through the tracing infrastructure.

These modifications align perfectly with our goal of streamlining the logging system and ensuring log crate output is shown with tracing.

Ohayo, sensei! Just a small suggestion to consider:

You might want to add a comment explaining the purpose of LogTracer::init()?; for future maintainers. Something like:

// Initialize LogTracer to capture logs from the `log` crate and forward them to `tracing`
LogTracer::init()?;

This will help others understand the importance of this line at a glance.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8453b63 and 8eaa1c2.

🔇 Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • Cargo.toml (1 hunks)
  • bin/katana/Cargo.toml (1 hunks)
  • bin/katana/src/cli/node.rs (2 hunks)
  • bin/saya/Cargo.toml (1 hunks)
  • bin/saya/src/args/mod.rs (2 hunks)
  • bin/sozo/Cargo.toml (1 hunks)
  • bin/sozo/src/args.rs (2 hunks)
🔇 Additional comments not posted (10)
bin/saya/Cargo.toml (1)

21-21: Ohayo, sensei! LGTM: Tracing-log addition looks great!

The addition of tracing-log.workspace = true is a solid move! This change aligns perfectly with our goal of ensuring the log crate output plays nice with tracing. By bringing tracing-log into the workspace, we're setting up a harmonious logging ecosystem across our project. Nicely done!

bin/katana/Cargo.toml (1)

30-30: Ohayo, sensei! LGTM: Adding tracing-log dependency

The addition of tracing-log to the dependencies is a great move! This crate bridges the gap between the log and tracing ecosystems, allowing log events to be captured by tracing subscribers. It aligns perfectly with the PR objective of ensuring log crate output is shown with tracing.

Using .workspace = true is also a wise choice, as it ensures consistent versioning across your project workspace. Keep up the excellent work, sensei!

bin/sozo/Cargo.toml (1)

59-59: Ohayo, sensei! This change looks great!

The update to use tracing-log.workspace = true aligns perfectly with the project's dependency management strategy. This change brings several benefits:

  1. Consistency: It matches the style used for other dependencies in this file.
  2. Simplified version management: By using the workspace-level dependency, it's easier to keep all parts of the project using the same version of tracing-log.
  3. Reduced maintenance: When updating tracing-log, you'll only need to change it in one place for the entire workspace.
bin/sozo/src/args.rs (2)

8-9: Ohayo, sensei! New imports look good!

The new imports for tracing_log and tracing_subscriber::FmtSubscriber are well-aligned with the changes in the logging initialization. They provide the necessary components for the updated implementation.


Line range hint 1-94: Ohayo, sensei! Overall, these changes are a solid improvement!

The modifications to the logging initialization process in this file are well-implemented and integrate smoothly with the existing code. The new imports and the updated init_logging method work together to provide a more robust and flexible logging configuration.

These changes align well with the PR objectives of ensuring the log crate output is shown with tracing. The introduction of tracing-log and the use of LogTracer should help achieve this goal.

Cargo.toml (2)

203-203: Ohayo, sensei! Excellent update to the tracing dependency!

The changes to the tracing dependency are well-thought-out:

  1. Updating to version 0.1.38 brings in the latest minor improvements.
  2. Adding the "log" feature enables seamless integration with the log crate.
  3. Disabling default features helps optimize the dependency tree.

These modifications align perfectly with the PR objective of ensuring log crate output is shown with tracing. Great job, sensei!


204-204: Ohayo again, sensei! Brilliant addition of the tracing-log dependency!

Adding the tracing-log crate (version 0.1.3) is a masterstroke:

  1. It provides the missing link between the tracing and log ecosystems.
  2. This addition perfectly complements the changes made to the tracing dependency.
  3. It directly supports the PR objective of ensuring log crate output is shown with tracing.

Your choice of version 0.1.3 is spot-on, as it's recent enough to be compatible with the updated tracing crate. Excellent work, sensei!

bin/saya/src/args/mod.rs (1)

15-15: Ohayo, sensei! Nice addition of the LogTracer.

The import of tracing_log::LogTracer is a great move to bridge the gap between the log and tracing crates. This will ensure that logs emitted via the log crate are captured and processed by tracing, aligning perfectly with our PR objectives.

bin/katana/src/cli/node.rs (2)

38-38: Ohayo, sensei! LGTM on this import!

The addition of use tracing_log::LogTracer; is well-placed and necessary for the upcoming LogTracer usage. It's grouped nicely with other tracing-related imports.


254-255: Ohayo again, sensei! This LogTracer initialization is sugoi!

The addition of LogTracer::init()?; is a crucial step in enhancing our logging capabilities. Here's why it's awesome:

  1. It routes log messages through the tracing framework, unifying our logging approach.
  2. Its placement before the fmt::Subscriber builder setup is perfect.
  3. The use of the ? operator ensures we handle any initialization errors gracefully.

The empty line after the initialization is a nice touch for readability. Domo arigato for this improvement!

Copy link

codecov bot commented Sep 25, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 4 lines in your changes missing coverage. Please review.

Project coverage is 68.45%. Comparing base (8453b63) to head (8eaa1c2).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
bin/saya/src/args/mod.rs 0.00% 3 Missing ⚠️
bin/katana/src/cli/node.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2477      +/-   ##
==========================================
- Coverage   68.45%   68.45%   -0.01%     
==========================================
  Files         368      368              
  Lines       48139    48153      +14     
==========================================
+ Hits        32955    32961       +6     
- Misses      15184    15192       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@glihm glihm merged commit 1e8ad6f into dojoengine:main Sep 25, 2024
14 of 15 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Oct 11, 2024
10 tasks
@coderabbitai coderabbitai bot mentioned this pull request Oct 30, 2024
2 tasks
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