File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55import os
66import sys
77import typing as t
8+ from datetime import datetime
89from functools import lru_cache
910
1011import uvicorn .config
1112from pydantic .v1 .utils import deep_update
13+ from rich .text import Text
1214
1315from constants import (
1416 DEFAULT_LOG_FORMAT ,
1921)
2022
2123
24+ def _ms_time_format (dt : datetime ) -> Text :
25+ """Format datetime object with zero padded milliseconds."""
26+ return Text (dt .strftime ("%Y-%m-%d %H:%M:%S." ) + f"{ dt .microsecond // 1000 :03d} " )
27+
28+
2229def resolve_log_level () -> int :
2330 """
2431 Resolve and validate the log level from environment variable.
@@ -87,7 +94,7 @@ def setup_logging() -> dict[t.Any, t.Any]:
8794 "rich" : {
8895 "()" : "rich.logging.RichHandler" ,
8996 "show_time" : True ,
90- "log_time_format" : "%Y-%m-%d %H:%M:%S.%f" ,
97+ "log_time_format" : _ms_time_format ,
9198 "level" : log_level ,
9299 },
93100 },
You can’t perform that action at this time.
0 commit comments