Add structured logging for Docker; support LOG_LEVEL env and --log-level
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user