Skip to content
Snippets Groups Projects
Select Git revision
  • 98d1d1571a130063725c60b28043de11b24f586b
  • develop default
  • master protected
  • inventoryProvider-functional
  • inventoryProvider-morework2
  • circuit-service-details-fix
  • lookup-SPECTRUM-SCHF-ports
  • inventoryProvider-1267-cleanup
  • inventoryProvider-moreWork
  • feature/DBOARD3-958
  • release/0.110
  • fix-uuid-validation-error
  • docker-poc
  • 0.160
  • 0.159
  • 0.158
  • 0.157
  • 0.156
  • 0.155
  • 0.154
  • 0.153
  • 0.152
  • 0.151
  • 0.150
  • 0.149
  • 0.148
  • 0.147
  • 0.146
  • 0.145
  • 0.144
  • 0.143
  • 0.142
  • 0.141
33 results

setup.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()))