Created
August 20, 2014 15:39
-
-
Save pferreir/5054bb731c868d2fda19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit f7db3494498071b2407fab388b2a058ac4835234 | |
Author: Pedro Ferreira <pedro.ferreira@cern.ch> | |
Date: Wed Aug 20 17:39:20 2014 +0200 | |
Avoid resetting loggers | |
Which creates problems with the scheduler's own logger | |
diff --git a/indico/core/logger.py b/indico/core/logger.py | |
index ef3a06f..c620264 100644 | |
--- a/indico/core/logger.py | |
+++ b/indico/core/logger.py | |
@@ -23,7 +23,7 @@ import logging | |
import logging.handlers | |
import logging.config | |
import ConfigParser | |
-from flask import request, session, current_app, has_app_context | |
+from flask import request, session | |
from ZODB.POSException import POSError | |
from indico.core.config import Config | |
@@ -238,12 +238,16 @@ class Logger: | |
cls.handlers.update(LoggerUtils.configFromFile(logConfFilepath, defaultArgs, filters)) | |
- if 'sentry' in config.getLoggers() and has_app_context(): | |
+ @classmethod | |
+ def post_app_creation(cls, app): | |
+ config = Config.getInstance() | |
+ | |
+ if 'sentry' in config.getLoggers(): | |
from raven.contrib.flask import Sentry | |
- current_app.config['SENTRY_DSN'] = config.getSentryDSN() | |
+ app.config['SENTRY_DSN'] = config.getSentryDSN() | |
# Plug into both Flask and `logging` | |
- Sentry(current_app, logging=True, level=getattr(logging, config.getSentryLoggingLevel())) | |
+ Sentry(app, logging=True, level=getattr(logging, config.getSentryLoggingLevel())) | |
@classmethod | |
def reset(cls): | |
diff --git a/indico/web/flask/app.py b/indico/web/flask/app.py | |
index 4b2e23b..b89bdf0 100644 | |
--- a/indico/web/flask/app.py | |
+++ b/indico/web/flask/app.py | |
@@ -251,8 +251,6 @@ def make_app(set_path=False, db_setup=True): | |
add_compat_blueprints(app) | |
add_plugin_blueprints(app) | |
- with app.app_context(): | |
- # re-establish loggers | |
- Logger.reset() | |
+ Logger.post_app_creation(app) | |
return app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment