Meme-Search-Engine/src/config.py

28 lines
713 B
Python

# Load configurationa YAML
import envyaml
import os
import logging
config = envyaml.envyaml(os.environ.get('CONFIG_PATH', 'config.yaml'))
def setLogLevel():
"""
Set the logging level based on the config
"""
logLevel = config["app.log"]
if logLevel == "DEBUG":
logging.basicConfig(level=logging.DEBUG)
elif logLevel == "INFO":
logging.basicConfig(level=logging.INFO)
elif logLevel == "WARNING":
logging.basicConfig(level=logging.WARNING)
elif logLevel == "ERROR":
logging.basicConfig(level=logging.ERROR)
elif logLevel == "CRITICAL":
logging.basicConfig(level=logging.CRITICAL)
logging.info("Logging level set to %s", logLevel)