Transcription-API/src/config.py

27 lines
664 B
Python

# Load configuration yaml
import envyaml
import os
import logging
config = envyaml.EnvYAML(os.environ.get('CONFIG_PATH', 'config.yaml'))
def setupLog():
logLevel = config["log.level"]
filename = config["log.filename"]
logFormat = config["log.format"]
level = None
if logLevel == "info":
level =logging.INFO
elif logLevel == "debug":
level = logging.DEBUG
elif logLevel == "warning":
level = logging.WARNING
elif logLevel == "error":
level = logging.ERROR
elif logLevel == "critical":
level = logging.CRITICAL
logging.basicConfig(level=level, filename=filename, format=logFormat)