Add --json-log flag to enable structured JSON logging (#19968)

Co-authored-by: github_username <github_email>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan Lee
2026-03-05 11:24:12 -08:00
committed by GitHub
co-authored by github_username <github_email> Claude Opus 4.6
parent 41fd53fe37
commit e58391dd7d
4 changed files with 18 additions and 1 deletions
+5
View File
@@ -260,6 +260,10 @@ struct CliArgs {
#[arg(long, default_value = "info", value_parser = ["debug", "info", "warn", "error"], help_heading = "Logging")]
log_level: String,
/// Enable structured JSON log output instead of plain text
#[arg(long, default_value_t = false, help_heading = "Logging")]
json_log: bool,
// ==================== Prometheus Metrics ====================
/// Port to expose Prometheus metrics
#[arg(long, default_value_t = 29000, help_heading = "Prometheus Metrics")]
@@ -1119,6 +1123,7 @@ impl CliArgs {
max_payload_size: self.max_payload_size,
log_dir: self.log_dir.clone(),
log_level: Some(self.log_level.clone()),
json_log: self.json_log,
service_discovery_config,
prometheus_config,
request_timeout_secs: self.request_timeout_secs,
+2 -1
View File
@@ -533,6 +533,7 @@ pub struct ServerConfig {
pub max_payload_size: usize,
pub log_dir: Option<String>,
pub log_level: Option<String>,
pub json_log: bool,
pub service_discovery_config: Option<ServiceDiscoveryConfig>,
pub prometheus_config: Option<PrometheusConfig>,
pub request_timeout_secs: u64,
@@ -722,7 +723,7 @@ pub async fn startup(config: ServerConfig) -> Result<(), Box<dyn std::error::Err
}
})
.unwrap_or(Level::INFO),
json_format: false,
json_format: config.json_log,
log_dir: config.log_dir.clone(),
colorize: true,
log_file_name: "smg".to_string(),