[Misc] add structure logging, write to file and log tracing for SGL Router

This commit is contained in:
Simo Lin
2025-04-27 16:54:10 -07:00
committed by GitHub
parent 86317c09e9
commit f0365820e8
10 changed files with 433 additions and 33 deletions

View File

@@ -23,6 +23,7 @@ def popen_launch_router(
policy: str = "cache_aware",
max_payload_size: int = None,
api_key: str = None,
log_dir: str = None,
):
"""
Launch the router server process.
@@ -35,6 +36,7 @@ def popen_launch_router(
policy: Router policy, one of "cache_aware", "round_robin", "random"
max_payload_size: Maximum payload size in bytes
api_key: API key for the router
log_dir: Directory to store log files. If None, logs are only output to console.
"""
_, host, port = base_url.split(":")
host = host[2:]
@@ -63,6 +65,9 @@ def popen_launch_router(
if max_payload_size is not None:
command.extend(["--router-max-payload-size", str(max_payload_size)])
if log_dir is not None:
command.extend(["--log-dir", log_dir])
process = subprocess.Popen(command, stdout=None, stderr=None)
start_time = time.time()