コード例 #1
0
ファイル: logger.py プロジェクト: sofian86/indico-gh-test
    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 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
ファイル: logger.py プロジェクト: OmeGak/indico
    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
ファイル: logger.py プロジェクト: pferreir/indico-backup
    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))