forked from NeptuneHub/AudioMuse-AI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_logging.py
More file actions
23 lines (17 loc) · 1.01 KB
/
app_logging.py
File metadata and controls
23 lines (17 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""Shared logging setup for every AudioMuse-AI entry point.
Call ``configure_logging()`` exactly once per process, as early as possible —
before any module that emits log records gets imported. ``logging.basicConfig``
is a no-op if the root logger already has a handler, so calling this helper
multiple times across imports is safe.
Why this exists: workers that don't import ``app`` (the high-priority worker,
the janitor) used to set up logging inline, with formats that drifted from
``app.py``. When one of them forgot to call ``basicConfig`` at all, every
``logger.info(...)`` from task modules fell through to Python's ``lastResort``
handler — silently dropping INFO-level output during long-running jobs.
"""
import logging
LOG_FORMAT = "[%(levelname)s]-[%(asctime)s]-%(message)s"
LOG_DATEFMT = "%d-%m-%Y %H-%M-%S"
def configure_logging(level: int = logging.INFO) -> None:
"""Install the project-wide root logger format. Idempotent."""
logging.basicConfig(level=level, format=LOG_FORMAT, datefmt=LOG_DATEFMT)