import json import logging.config import os def setup_logging(): """ set up logging using the configured filename if LOGGING_CONFIG is defined in the environment, use this for the filename, otherwise use logging_default_config.json """ default_filename = os.path.join( os.path.dirname(__file__), 'logging_default_config.json') filename = os.getenv('LOGGING_CONFIG', default_filename) with open(filename) as f: # TODO: this mac workaround should be removed ... d = json.loads(f.read()) import platform if platform.system() == 'Darwin': d['handlers']['syslog_handler']['address'] = '/var/run/syslog' logging.config.dictConfig(d) # logging.config.dictConfig(json.loads(f.read()))