Пример #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
    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))
Пример #3
0
    def initialize(cls):
        # Lists of filters for each handler
        filters = {
            "indico": [AddIDFilter("indico")],
            "other": [ExtraIndicoFilter()],
            "celery": [CeleryFilter()],
            "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"),
                "celery": ("FileHandler", "('%s', 'a')" % cls._log_path("celery.log"), "DEBUG"),
                "stderr": ("StreamHandler", "()", "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))
Пример #4
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))