Skip to content
Snippets Groups Projects
Select Git revision
  • 03b0b78b5141df34722e868a59272486a7a9a062
  • develop default protected
  • master protected
  • feature/POL1-813-error-report-sensu-check
  • 0.22
  • 0.21
  • 0.20
  • 0.19
  • 0.18
  • 0.17
  • 0.16
  • 0.15
  • 0.14
  • 0.13
  • 0.12
  • 0.11
  • 0.10
  • 0.9
  • 0.8
  • 0.7
  • 0.6
  • 0.5
  • 0.4
  • 0.3
24 results

app.py

Blame
  • environment.py 1.10 KiB
    import json
    import logging.config
    import os
    from importlib.metadata import distribution
    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=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()))