Newer
Older
import json
import logging.config
import os
import pkg_resources
import sentry_sdk
from sentry_sdk.integrations.flask import FlaskIntegration
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)
sentry_dsn = os.getenv('SENTRY_DSN')
if sentry_dsn:
sentry_sdk.init(
dsn=sentry_dsn,
integrations=[FlaskIntegration()],
release=pkg_resources.get_distribution('brian-dashboard-manager').version)
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()))