예제 #1
0
    def initialize(cls):
        # Lists of filters for each handler
        filters = {'indico': [AddIDFilter('indico')],
                   'other': [ExtraIndicoFilter()],
                   'smtp': [AddIDFilter('indico')]}

        config = Config.getInstance()

        if 'files' in config.getLoggers():
            logConfFilepath = os.path.join(config.getConfigurationDir(), 'logging.conf')
            smtpServer = config.getSmtpServer()
            serverName = config.getWorkerName()
            if not serverName:
                serverName = config.getHostNameURL()

            # Default arguments for the handlers, taken mostly for the configuration
            defaultArgs = {
                'indico': ("FileHandler", "('%s', 'a')" % cls._log_path('indico.log'), 'DEBUG'),
                'other': ("FileHandler", "('%s', 'a')" % cls._log_path('other.log'), 'DEBUG'),
                'smtp': (
                    "handlers.SMTPHandler", "(%s, 'logger@%s', ['%s'], 'Unexpected Exception occurred at %s')"
                    % (smtpServer, serverName, config.getSupportEmail(), serverName), "ERROR")
            }

            cls.handlers.update(LoggerUtils.configFromFile(logConfFilepath, defaultArgs, filters))

        if 'sentry' in config.getLoggers() and has_app_context():
            from raven.contrib.flask import Sentry
            current_app.config['SENTRY_DSN'] = config.getSentryDSN()

            # Plug into both Flask and `logging`
            Sentry(current_app, logging=True, level=getattr(logging, config.getSentryLoggingLevel()))
예제 #2
0
파일: logger.py 프로젝트: NIIF/indico
    def init_app(cls, app):
        """
        Initialize Flask app logging (add Sentry if needed)
        """
        config = Config.getInstance()

        if 'sentry' in config.getLoggers():
            from raven.contrib.flask import Sentry
            app.config['SENTRY_DSN'] = config.getSentryDSN()

            # Plug into both Flask and `logging`
            Sentry(app, logging=True, level=getattr(logging, config.getSentryLoggingLevel()))
예제 #3
0
    def init_app(cls, app):
        """
        Initialize Flask app logging (add Sentry if needed)
        """
        config = Config.getInstance()

        if 'sentry' in config.getLoggers():
            from raven.contrib.flask import Sentry
            app.config['SENTRY_DSN'] = config.getSentryDSN()

            # Plug into both Flask and `logging`
            Sentry(app, logging=True, level=getattr(logging, config.getSentryLoggingLevel()))