mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
fix(budget): log warning on timezone fallback to UTC
When ZoneInfo fails to load a configured timezone (e.g. missing tzdata), the code silently falls back to UTC. Add a verbose_logger.warning() so operators can see which timezone failed and how to fix it.
This commit is contained in:
parent
6e09a52456
commit
43972a414d
1 changed files with 7 additions and 1 deletions
|
|
@ -12,6 +12,8 @@ from datetime import datetime, timedelta, timezone, tzinfo
|
|||
from typing import Optional, Tuple
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from litellm._logging import verbose_logger
|
||||
|
||||
|
||||
def _extract_from_regex(duration: str) -> Tuple[int, str]:
|
||||
match = re.match(r"(\d+)(mo|[smhdw]?)", duration)
|
||||
|
|
@ -156,7 +158,11 @@ def _setup_timezone(
|
|||
else:
|
||||
tz = ZoneInfo(timezone_str)
|
||||
except Exception:
|
||||
# If timezone is invalid, fall back to UTC
|
||||
verbose_logger.warning(
|
||||
"Failed to load timezone '%s', falling back to UTC. "
|
||||
"Install 'tzdata' package for full timezone support.",
|
||||
timezone_str,
|
||||
)
|
||||
tz = timezone.utc
|
||||
|
||||
# Convert current_time to the target timezone
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue