mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-20 00:11:50 +00:00
LITELLM_LOG=ERROR still printed INFO lines from uvicorn (startup and access log) and from the litellm_proxy_extras migration logger, because neither read the variable. Forward the resolved level to uvicorn when LITELLM_LOG is set and no explicit log_config or JSON logging is in use, and let the extras logger take its level from LITELLM_LOG Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
import importlib
|
|
import logging
|
|
|
|
import pytest
|
|
|
|
import litellm_proxy_extras._logging as extras_logging
|
|
|
|
|
|
def test_litellm_log_error_silences_extras_info_lines(monkeypatch):
|
|
saved_handlers = logging.getLogger("litellm_proxy_extras").handlers[:]
|
|
monkeypatch.setenv("LITELLM_LOG", "ERROR")
|
|
logging.getLogger("litellm_proxy_extras").handlers[:] = []
|
|
try:
|
|
reloaded = importlib.reload(extras_logging).logger
|
|
assert reloaded.isEnabledFor(logging.INFO) is False
|
|
assert reloaded.isEnabledFor(logging.ERROR) is True
|
|
finally:
|
|
logging.getLogger("litellm_proxy_extras").handlers[:] = saved_handlers
|
|
logging.getLogger("litellm_proxy_extras").setLevel(logging.INFO)
|
|
|
|
|
|
@pytest.mark.parametrize("litellm_log", [None, "info", "DEBUG"])
|
|
def test_unset_or_verbose_litellm_log_keeps_extras_info_lines(monkeypatch, litellm_log):
|
|
saved_handlers = logging.getLogger("litellm_proxy_extras").handlers[:]
|
|
if litellm_log is None:
|
|
monkeypatch.delenv("LITELLM_LOG", raising=False)
|
|
else:
|
|
monkeypatch.setenv("LITELLM_LOG", litellm_log)
|
|
logging.getLogger("litellm_proxy_extras").handlers[:] = []
|
|
try:
|
|
assert importlib.reload(extras_logging).logger.isEnabledFor(logging.INFO) is True
|
|
finally:
|
|
logging.getLogger("litellm_proxy_extras").handlers[:] = saved_handlers
|
|
logging.getLogger("litellm_proxy_extras").setLevel(logging.INFO)
|