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 14:24:12 -05:00
committed by GitHub
parent 41fd53fe37
commit e58391dd7d
4 changed files with 18 additions and 1 deletions

View File

@@ -354,6 +354,7 @@ struct Router {
api_key: Option<String>,
log_dir: Option<String>,
log_level: Option<String>,
json_log: bool,
service_discovery: bool,
selector: HashMap<String, String>,
service_discovery_port: u16,
@@ -657,6 +658,7 @@ impl Router {
api_key = None,
log_dir = None,
log_level = None,
json_log = false,
service_discovery = false,
selector = HashMap::new(),
service_discovery_port = 80,
@@ -743,6 +745,7 @@ impl Router {
api_key: Option<String>,
log_dir: Option<String>,
log_level: Option<String>,
json_log: bool,
service_discovery: bool,
selector: HashMap<String, String>,
service_discovery_port: u16,
@@ -842,6 +845,7 @@ impl Router {
api_key,
log_dir,
log_level,
json_log,
service_discovery,
selector,
service_discovery_port,
@@ -963,6 +967,7 @@ impl Router {
max_payload_size: self.max_payload_size,
log_dir: self.log_dir.clone(),
log_level: self.log_level.clone(),
json_log: self.json_log,
service_discovery_config,
prometheus_config,
request_timeout_secs: self.request_timeout_secs,

View File

@@ -45,6 +45,7 @@ class RouterArgs:
api_key: Optional[str] = None
log_dir: Optional[str] = None
log_level: Optional[str] = None
json_log: bool = False
# Service discovery configuration
service_discovery: bool = False
selector: Dict[str, str] = dataclasses.field(default_factory=dict)
@@ -413,6 +414,11 @@ class RouterArgs:
choices=["debug", "info", "warn", "error"],
help="Set the logging level. If not specified, defaults to INFO.",
)
logging_group.add_argument(
f"--{prefix}json-log",
action="store_true",
help="Enable structured JSON log output instead of plain text.",
)
# Service discovery configuration
k8s_group.add_argument(