[log]console log to llm log (#5680)

This commit is contained in:
xiaolei373
2025-12-23 10:05:45 +08:00
committed by GitHub
parent 131defa122
commit dfe8ea941c
2 changed files with 6 additions and 6 deletions
@@ -18,7 +18,7 @@ import os
import shutil import shutil
import uuid import uuid
from fastdeploy.utils import console_logger from fastdeploy.utils import llm_logger
def setup_multiprocess_prometheus(): def setup_multiprocess_prometheus():
@@ -33,12 +33,12 @@ def setup_multiprocess_prometheus():
if os.path.exists(prom_dir): if os.path.exists(prom_dir):
shutil.rmtree(prom_dir, ignore_errors=True) shutil.rmtree(prom_dir, ignore_errors=True)
os.makedirs(prom_dir, exist_ok=True) os.makedirs(prom_dir, exist_ok=True)
console_logger.info(f"PROMETHEUS_MULTIPROC_DIR is set to be {prom_dir}") llm_logger.info(f"PROMETHEUS_MULTIPROC_DIR is set to be {prom_dir}")
os.environ["PROMETHEUS_MULTIPROC_DIR"] = prom_dir os.environ["PROMETHEUS_MULTIPROC_DIR"] = prom_dir
return prom_dir return prom_dir
else: else:
prom_dir = os.environ["PROMETHEUS_MULTIPROC_DIR"] prom_dir = os.environ["PROMETHEUS_MULTIPROC_DIR"]
console_logger.warning( llm_logger.warning(
f"Found PROMETHEUS_MULTIPROC_DIR:{prom_dir} was set by user. " f"Found PROMETHEUS_MULTIPROC_DIR:{prom_dir} was set by user. "
"you will find inaccurate metrics. Unset the variable " "you will find inaccurate metrics. Unset the variable "
"will properly handle cleanup." "will properly handle cleanup."
@@ -37,7 +37,7 @@ class TestSetupMultiprocessPrometheus:
with ( with (
patch("uuid.uuid4", return_value="test-uuid"), patch("uuid.uuid4", return_value="test-uuid"),
patch("fastdeploy.utils.console_logger.info") as mock_logger, patch("fastdeploy.utils.llm_logger.info") as mock_logger,
): ):
result = setup_multiprocess_prometheus() result = setup_multiprocess_prometheus()
@@ -51,7 +51,7 @@ class TestSetupMultiprocessPrometheus:
test_dir = "/tmp/existing_dir" test_dir = "/tmp/existing_dir"
os.environ["PROMETHEUS_MULTIPROC_DIR"] = test_dir os.environ["PROMETHEUS_MULTIPROC_DIR"] = test_dir
with patch("fastdeploy.utils.console_logger.warning") as mock_logger: with patch("fastdeploy.utils.llm_logger.warning") as mock_logger:
result = setup_multiprocess_prometheus() result = setup_multiprocess_prometheus()
assert result == test_dir assert result == test_dir
@@ -69,7 +69,7 @@ class TestSetupMultiprocessPrometheus:
with ( with (
patch("os.path.exists", return_value=True), patch("os.path.exists", return_value=True),
patch("uuid.uuid4", return_value="test-uuid"), patch("uuid.uuid4", return_value="test-uuid"),
patch("fastdeploy.utils.console_logger.info") as mock_logger, patch("fastdeploy.utils.llm_logger.info") as mock_logger,
): ):
# 模拟 rmtree 但确保 ignore_errors=True 生效 # 模拟 rmtree 但确保 ignore_errors=True 生效