Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions utils/logging_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import logging

LOG_FORMAT = "%(asctime)s %(levelname)s [%(name)s] %(message)s"
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
# reduce noise from overly-verbose libraries
logging.getLogger("urllib3").setLevel(logging.WARNING)
logging.getLogger("PIL").setLevel(logging.WARNING)

# Expose a convenience function for other modules to use when they want
# to ensure logging is configured (idempotent).

def configure_logging(level: int = logging.INFO) -> None:
"""Configure root logging for the application.

This is safe to call multiple times; subsequent calls will not reconfigure
handlers if they've already been set up by basicConfig.
"""
logging.getLogger().setLevel(level)
Loading