Add full year and milliseconds to log timestamp (#4954)

This synchronizes log timestamps with how Home Assistant Core formats
them: Using the full 4 digit year and milliseconds precision.

See also https://github.com/home-assistant/core/pull/74518.
This commit is contained in:
Stefan Agner 2024-03-15 17:50:01 +01:00 committed by GitHub
parent a8af04ff82
commit b15a5c2c87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -256,9 +256,11 @@ def migrate_system_env(coresys: CoreSys) -> None:
def initialize_logging() -> None:
"""Initialize the logging."""
logging.basicConfig(level=logging.INFO)
fmt = "%(asctime)s %(levelname)s (%(threadName)s) [%(name)s] %(message)s"
fmt = (
"%(asctime)s.%(msecs)03d %(levelname)s (%(threadName)s) [%(name)s] %(message)s"
)
colorfmt = f"%(log_color)s{fmt}%(reset)s"
datefmt = "%y-%m-%d %H:%M:%S"
datefmt = "%Y-%m-%d %H:%M:%S"
# suppress overly verbose logs from libraries that aren't helpful
logging.getLogger("aiohttp.access").setLevel(logging.WARNING)