# NOTE: would have used Sanic, but wasn't as familiar with it vs flask at the time

import os
import yaml
import logging.config

def setup_logging(
    default_path='logging.yaml',
    default_level=logging.INFO,
    env_key='LOG_CONFIG'
):
    """Setup logging configuration"""
    path = default_path
    value = os.getenv(env_key, None)
    if value:
        path = value

        print "Opening " + path
    if os.path.exists(path):
        print "Opening " + path
        with open(path, 'rt') as f:
            config = yaml.safe_load(f.read())
        logging.config.dictConfig(config)
    else:
        logging.basicConfig(level=default_level)

setup_logging()
