import logging import os import yaml def enable_logs(path='configs/logs.yml'): """Loads logging configuration and set up logger(s) For more details on logging configuration options: https://docs.python.org/3.4/howto/logging.html#configuring-logging """ if os.path.exists(path): with open(path, 'rt') as f: config = yaml.load(f.read()) logging.config.dictConfig(config.get('log')) else: raise FileNotFoundError('File "%s" does not exist' % path)