Skip to content
Snippets Groups Projects
Select Git revision
  • 42ad0fbde4a9bc90c42df0cf93305dedf7c61869
  • develop default
  • master protected
  • async-provision
  • DBOARD3-1252/inventory-api
  • 0.90
  • 0.89
  • 0.88
  • 0.87
  • 0.86
  • 0.85
  • 0.84
  • 0.83
  • 0.82
  • 0.81
  • 0.80
  • 0.79
  • 0.78
  • 0.77
  • 0.76
  • 0.75
  • 0.74
  • 0.73
  • 0.72
  • 0.71
25 results

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