Add structured logging for Docker; support LOG_LEVEL env and --log-level
Mirror and run GitLab CI / build (push) Has been cancelled
Ruff / ruff (push) Has been cancelled

This commit is contained in:
admin
2026-06-13 17:46:25 +00:00
parent 47b3304297
commit 2ea46ada42
5 changed files with 140 additions and 9 deletions
+20
View File
@@ -1,4 +1,5 @@
import os
import logging
from argparse import Action
from ast import literal_eval
@@ -13,6 +14,25 @@ PYANNOTE_DEFAULT_PATH = os.path.join(CACHE_DIR, "pyannote")
PYANNOTE_DEFAULT_CONFIG = os.path.join(PYANNOTE_DEFAULT_PATH, "config.yaml")
def setup_logging(level: str = "INFO"):
"""
Configure root logger to write to stdout so Docker can capture logs.
Args:
level: Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL).
"""
numeric_level = getattr(logging, level.upper(), logging.INFO)
if not isinstance(numeric_level, int):
numeric_level = logging.INFO
logging.basicConfig(
level=numeric_level,
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
datefmt="%Y-%m-%dT%H:%M:%S%z",
force=True,
)
def set_threads(parse_threads=None, yaml_threads=None):
"""
Configure number of threads.