Skip to content

Conversation

@Evrard-Nil
Copy link
Collaborator

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the service mesh logging configuration to support JSON-formatted logs. The changes enable environment-based control of log format and verbosity, making the application more suitable for production deployment where structured logging is beneficial for log aggregation systems.

  • Adds JSON logging support via LOG_FORMAT environment variable (defaults to JSON)
  • Implements environment-based log level filtering via RUST_LOG variable
  • Adds tracing-subscriber JSON feature and related dependencies

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
service-mesh/src/main.rs Replaces static tracing initialization with configurable JSON/pretty format logging based on environment variables
service-mesh/Cargo.toml Adds "json" feature to tracing-subscriber dependency and reformats multi-feature dependencies for better readability
Cargo.lock Updates lock file with new tracing-serde dependency required for JSON logging support

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

let env_filter = tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info"));

if log_format == "json" {
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The string comparison for log format is case-sensitive and doesn't handle variations like "JSON", "Json", or invalid values gracefully. Consider using a case-insensitive comparison or matching against known valid values:

if log_format.eq_ignore_ascii_case("json") {
    // json format
} else {
    // pretty format (default for anything else)
}

Alternatively, you could explicitly handle invalid values and log a warning when an unrecognized format is specified.

Copilot uses AI. Check for mistakes.
.with_max_level(tracing::Level::DEBUG)
.init();
// Initialize tracing from environment (RUST_LOG)
// Use LOG_FORMAT=json or LOG_FORMAT=pretty (default: json)
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The comment mentions "LOG_FORMAT=pretty" as an option, but the code doesn't explicitly check for "pretty" - it treats any non-"json" value as pretty format. Consider updating the comment to clarify this behavior:

// Initialize tracing from environment (RUST_LOG)
// Use LOG_FORMAT=json for JSON output, any other value uses pretty format (default: json)
Suggested change
// Use LOG_FORMAT=json or LOG_FORMAT=pretty (default: json)
// Use LOG_FORMAT=json for JSON output, any other value uses pretty format (default: json)

Copilot uses AI. Check for mistakes.
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