Esempio n. 1
0
def pytest_configure(config):
    if config.getoption('logging_level'):
        # Forward IPA logging to a normal Python logger. Nose's logcapture plugin
        # can't work with IPA-managed loggers
        class LogHandler(logging.Handler):
            name = 'forwarding log handler'
            logger = logging.getLogger('IPA')

            def emit(self, record):
                capture = config.pluginmanager.getplugin('capturemanager')
                orig_stdout, orig_stderr = sys.stdout, sys.stderr
                if capture:
                    capture._capturing.suspend_capturing()
                sys.stderr.write(self.format(record))
                sys.stderr.write('\n')
                if capture:
                    capture._capturing.resume_capturing()
                sys.stdout, sys.stderr = orig_stdout, orig_stderr

        log_mgr.configure(
            {
                'default_level':
                config.getoption('logging_level'),
                'handlers': [{
                    'log_handler': LogHandler(),
                    'format': '[%(name)s] %(message)s',
                    'level': 'debug'
                }, {
                    'level': 'debug',
                    'name': 'real_stderr',
                    'stream': sys.stderr
                }]
            },
            configure_state='tests')
Esempio n. 2
0
def pytest_configure(config):
    if config.getoption('logging_level'):
        # Forward IPA logging to a normal Python logger. Nose's logcapture plugin
        # can't work with IPA-managed loggers
        class LogHandler(logging.Handler):
            name = 'forwarding log handler'
            logger = logging.getLogger('IPA')

            def emit(self, record):
                capture = config.pluginmanager.getplugin('capturemanager')
                orig_stdout, orig_stderr = sys.stdout, sys.stderr
                if capture:
                    capture._capturing.suspend_capturing()
                sys.stderr.write(self.format(record))
                sys.stderr.write('\n')
                if capture:
                    capture._capturing.resume_capturing()
                sys.stdout, sys.stderr = orig_stdout, orig_stderr

        log_mgr.configure(
            {
                'default_level': config.getoption('logging_level'),
                'handlers': [{'log_handler': LogHandler(),
                            'format': '[%(name)s] %(message)s',
                            'level': 'debug'},
                            {'level': 'debug',
                            'name': 'real_stderr',
                            'stream': sys.stderr}]},
            configure_state='tests')
Esempio n. 3
0
 def setup_log_handler(self, handler):
     log_mgr.configure(
         {
             'default_level': 'DEBUG',
             'handlers': [{'log_handler': handler,
                           'format': '[%(name)s] %(message)s',
                           'level': 'info'}]},
         configure_state='beakerlib_plugin')
Esempio n. 4
0
def pytest_configure(config):
    plugin = config.pluginmanager.getplugin('BeakerLibPlugin')
    if plugin:
        handler = BeakerLibLogHandler(plugin.run_beakerlib_command)
        log_mgr.configure(
            {
                'default_level': 'DEBUG',
                'handlers': [{'log_handler': handler,
                              'format': '[%(name)s] %(message)s',
                              'level': 'info'}]},
            configure_state='beakerlib_plugin')
Esempio n. 5
0
    def run(self):
        super(IpaAdvise, self).run()

        api.bootstrap(in_server=False, context='cli')
        api.finalize()
        advise_api.bootstrap(in_server=False, context='cli')
        advise_api.finalize()
        if not self.options.verbose:
            # Do not print connection information by default
            logger_name = r'ipa\.ipalib\.plugins\.rpcclient'
            log_mgr.configure(dict(logger_regexps=[(logger_name, 'warning')]))

        # With no argument, print the list out and exit
        if not self.args:
            self.print_config_list()
            return
        else:
            keyword = self.args[0].replace('-', '_')
            self.print_advice(keyword)
Esempio n. 6
0
    def run(self):
        super(IpaAdvise, self).run()

        api.bootstrap(in_server=False, context='cli')
        api.finalize()
        advise_api.bootstrap(in_server=False, context='cli')
        advise_api.finalize()
        if not self.options.verbose:
            # Do not print connection information by default
            logger_name = r'ipa\.ipalib\.plugins\.rpcclient'
            log_mgr.configure(dict(logger_regexps=[(logger_name, 'warning')]))

        # With no argument, print the list out and exit
        if not self.args:
            self.print_config_list()
            return
        else:
            keyword = self.args[0].replace('-', '_')
            self.print_advice(keyword)