def init_logging(app): location_log_config = app.config['LOGGING_CONFIG_LOCATION'] if os.path.isfile(location_log_config): logging.config.fileConfig(location_log_config, disable_existing_loggers=True) logger.info('Loaded logging configuration file "%s"', location_log_config) else: logger.warning('Error loading configuration file "%s"', location_log_config) if app.config['SENTRY_DSN']: # This could not be done in the default .ini because the # handler has to be passed to `raven.setup_logging`. # the following adds itself to app.extensions['sentry'] sentry = Sentry() sentry.init_app(app, dsn=app.config['SENTRY_DSN']) handler = SentryHandler(app.extensions['sentry'].client) handler.level = logging.NOTSET setup_logging(handler) logger.debug("Sentry DSN: {}".format(app.config['SENTRY_DSN'])) else: logger.debug("No sentry DSN specified")
def register_sentry_handler(): handler = SentryHandler() handler.client = app.extensions['sentry'].client setup_logging(handler) return handler
def _init_sentry(app): if app.config['ENABLE_SENTRY']: sentry = Sentry(app) sentry_handler = SentryHandler(sentry.client) sentry_handler.setLevel(logging.WARNING) app.logger.addHandler(sentry_handler) setup_logging(sentry_handler)
def make_sentry_logger(): client = raven.Client( dsn=os.environ["SENTRY_DSN"], release=VERSION, processor=SanitizePasswordsProcessor, ) handler = SentryHandler(client) handler.setLevel(logging.WARNING) setup_logging(handler)
def _set_up_logger(sentry_client): config = hermes.get_config('config.json', {}) log_level_from_config = str(config.get('log_level')).upper() log_level = getattr(logging, log_level_from_config, logging.INFO) logging.basicConfig( level=log_level, format='%(asctime)s %(name)s [%(levelname)s] - %(message)s') handler = SentryHandler(sentry_client, level=logging.WARNING) setup_logging(handler)
def setup_sentry(): sentry_url = hermes.get_config('config.json').get('sentry_url', '') sentry_client = Client(sentry_url, auto_log_stacks=True, ignore_exceptions=sentry_ignore_exceptions, ) handler = SentryHandler(sentry_client, level=logging.WARNING) setup_logging(handler) return sentry_client
def init_sentry(app): sentry = IndicoSentry(wrap_wsgi=False, register_signal=True, logging=False) sentry.init_app(app) # setup logging manually and exclude uncaught indico exceptions. # these are logged manually in the flask error handler logic so # we get the X-Sentry-ID header which is not populated in the # logging handlers handler = SentryHandler(sentry.client, level=getattr(logging, config.SENTRY_LOGGING_LEVEL)) handler.addFilter(BlacklistFilter({'indico.flask', 'celery.redirected'})) setup_logging(handler) # connect to the celery logger register_logger_signal(sentry.client) register_signal(sentry.client)
def setup_sentry(): sentry_url = get_ship_config().get('sentry_url', '') tags = {'ship_IP': get_external_ip()} sentry_client = Client(sentry_url, include_paths=sentry_include_path, release=__version__, auto_log_stacks=True, ignore_exceptions=sentry_ignore_exceptions, tags=tags) handler = SentryHandler(sentry_client, level=logging.WARNING) setup_logging(handler) return sentry_client
def setup_sentry(is_web=False): sentry_url = get_ship_config().get('sentry_url', '') client_class = WebSentryClient if is_web else Client tags = {'ship_IP': get_external_ip()} sentry_client = client_class(sentry_url, include_paths=sentry_include_path, release=__version__, auto_log_stacks=True, ignore_exceptions=sentry_ignore_exceptions, tags=tags) handler = SentryHandler(sentry_client, level=logging.WARNING) setup_logging(handler) return sentry_client
#!/usr/bin/env python import os import sys import logging if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "leela.settings") from django.core.management import execute_from_command_line from raven import setup_logging from raven.contrib.django.handlers import SentryHandler setup_logging(SentryHandler(level=logging.WARNING)) execute_from_command_line(sys.argv)
def configure_logging(self, level=None, **kwargs): exlcude = kwargs.pop('logging_exclusions', None) if exlcude: kwargs['exclude'] = exlcude setup_logging(SentryHandler(self.client, level=level), **kwargs)
}, } dictConfig(LOGGING) RAVEN_CONFIG = { 'dsn': 'https://*****:*****@sentry.io/98255', # If you are using git, you can also automatically configure the # release based on the git info. 'release': raven.fetch_git_sha(os.path.join(os.path.dirname(__file__), '..')), } handler = SentryHandler( 'https://*****:*****@sentry.io/53555' ) raven.setup_logging(handler) COPY_START_YEAR = 2016 VERSION = 'v0.0.001' # Propeller WebIDE settings WEBIDE_GIT_ROOT = config.get("project", "root") # Export settings to use in templates SETTINGS_EXPORT = [ 'USE_CDN', 'VERSION', ]