Ejemplo n.º 1
0
 def __init__(self, settings):
     AbstractLogger.__init__(self)
     self._xmllogger = XmlLogger(settings['Output'], settings['LogLevel'],
                                 settings['SplitOutputs'])
     self._register_loggers(settings['Listeners'], settings['DebugFile'])
     self._namegen = self._get_log_name_generator(settings['Log'])
     self._settings = settings
     robot.output.OUTPUT = self
class Output(AbstractLogger):

    def __init__(self, settings):
        AbstractLogger.__init__(self)
        self._xmllogger = XmlLogger(settings['Output'], settings['LogLevel'])
        self._register_loggers(settings['Listeners'], settings['DebugFile'])
        self._settings = settings
        self._set_global_output()

    def _register_loggers(self, listeners, debugfile):
        LOGGER.register_context_changing_logger(self._xmllogger)
        for logger in Listeners(listeners), DebugFile(debugfile):
            if logger: LOGGER.register_logger(logger)
        LOGGER.disable_message_cache()

    def _set_global_output(self):
        # This is a hack. Hopefully we get rid of it at some point.
        from robot import output
        output.OUTPUT = self

    def close(self, suite):
        stats = Statistics(suite, self._settings['SuiteStatLevel'],
                           self._settings['TagStatInclude'],
                           self._settings['TagStatExclude'],
                           self._settings['TagStatCombine'],
                           self._settings['TagDoc'],
                           self._settings['TagStatLink'])
        stats.serialize(self._xmllogger)
        self._xmllogger.close()
        LOGGER.unregister_logger(self._xmllogger)
        LOGGER.output_file('Output', self._settings['Output'])

    def start_suite(self, suite):
        LOGGER.start_suite(suite)

    def end_suite(self, suite):
        LOGGER.end_suite(suite)

    def start_test(self, test):
        LOGGER.start_test(test)

    def end_test(self, test):
        LOGGER.end_test(test)

    def start_keyword(self, kw):
        LOGGER.start_keyword(kw)

    def end_keyword(self, kw):
        LOGGER.end_keyword(kw)

    def message(self, msg):
        LOGGER.log_message(msg)

    def set_log_level(self, level):
        return self._xmllogger.set_log_level(level)
Ejemplo n.º 3
0
 def __init__(self, settings):
     AbstractLogger.__init__(self)
     self._xmllogger = XmlLogger(settings['Output'], settings['LogLevel'],
                                 settings['SplitOutputs'])
     self._register_loggers(settings['Listeners'], settings['DebugFile'])
     self._namegen = self._get_log_name_generator(settings['Log'])
     self._settings = settings
     robot.output.OUTPUT = self
Ejemplo n.º 4
0
class Output(AbstractLogger):

    def __init__(self, settings):
        AbstractLogger.__init__(self)
        self._xmllogger = XmlLogger(settings['Output'], settings['LogLevel'],
                                    settings['SplitOutputs'])
        self._register_loggers(settings['Listeners'], settings['DebugFile'])
        self._namegen = self._get_log_name_generator(settings['Log'])
        self._settings = settings
        robot.output.OUTPUT = self

    def _register_loggers(self, listeners, debugfile):
        LOGGER.register_logger(self._xmllogger)
        for logger in Listeners(listeners), DebugFile(debugfile):
            if logger: LOGGER.register_logger(logger)
        LOGGER.disable_message_cache()

    def _get_log_name_generator(self, log):
        return log != 'NONE' and utils.FileNameGenerator(log) or None

    def close(self, suite):
        stats = Statistics(suite, self._settings['SuiteStatLevel'],
                           self._settings['TagStatInclude'],
                           self._settings['TagStatExclude'],
                           self._settings['TagStatCombine'],
                           self._settings['TagDoc'],
                           self._settings['TagStatLink'])
        stats.serialize(self._xmllogger)
        self._xmllogger.close(serialize_errors=True)
        LOGGER.unregister_logger(self._xmllogger)
        LOGGER.output_file('Output', self._settings['Output'])

    def start_suite(self, suite):
        LOGGER.start_suite(suite)
        if self._xmllogger.started_output:
            suite.context.output_file_changed(self._xmllogger.started_output)
            if self._namegen:
                suite.context.log_file_changed(self._namegen.get_name())

    def end_suite(self, suite):
        LOGGER.end_suite(suite)
        if self._xmllogger.ended_output:
            LOGGER.output_file('Output', self._xmllogger.ended_output)
            orig_outpath = self._settings['Output']
            suite.context.output_file_changed(orig_outpath)
            self._create_split_log(self._xmllogger.ended_output, suite)

    def _create_split_log(self, outpath, suite):
        if self._namegen is None:
            return
        logpath = self._namegen.get_prev()
        output = robot.serializing.SplitSubTestOutput(outpath)
        output.serialize_log(logpath)
        suite.context.log_file_changed(self._namegen.get_base())

    def start_test(self, test):
        LOGGER.start_test(test)

    def end_test(self, test):
        LOGGER.end_test(test)

    def start_keyword(self, kw):
        LOGGER.start_keyword(kw)

    def end_keyword(self, kw):
        LOGGER.end_keyword(kw)

    def log_output(self, output):
        """Splits given output to levels and messages and logs them"""
        for msg in _OutputSplitter(output):
            self.message(msg)

    def message(self, msg):
        LOGGER.log_message(msg)

    def set_log_level(self, level):
        return self._xmllogger.set_log_level(level)
 def __init__(self, settings):
     AbstractLogger.__init__(self)
     self._xmllogger = XmlLogger(settings['Output'], settings['LogLevel'])
     self._register_loggers(settings['Listeners'], settings['DebugFile'])
     self._settings = settings
     self._set_global_output()
Ejemplo n.º 6
0
class Output(AbstractLogger):
    def __init__(self, settings):
        AbstractLogger.__init__(self)
        self._xmllogger = XmlLogger(settings['Output'], settings['LogLevel'],
                                    settings['SplitOutputs'])
        self._register_loggers(settings['Listeners'], settings['DebugFile'])
        self._namegen = self._get_log_name_generator(settings['Log'])
        self._settings = settings
        robot.output.OUTPUT = self

    def _register_loggers(self, listeners, debugfile):
        LOGGER.register_logger(self._xmllogger)
        for logger in Listeners(listeners), DebugFile(debugfile):
            if logger: LOGGER.register_logger(logger)
        LOGGER.disable_message_cache()

    def _get_log_name_generator(self, log):
        return log != 'NONE' and utils.FileNameGenerator(log) or None

    def close(self, suite):
        stats = Statistics(suite, self._settings['SuiteStatLevel'],
                           self._settings['TagStatInclude'],
                           self._settings['TagStatExclude'],
                           self._settings['TagStatCombine'],
                           self._settings['TagDoc'],
                           self._settings['TagStatLink'])
        stats.serialize(self._xmllogger)
        self._xmllogger.close(serialize_errors=True)
        LOGGER.unregister_logger(self._xmllogger)
        LOGGER.output_file('Output', self._settings['Output'])

    def start_suite(self, suite):
        LOGGER.start_suite(suite)
        if self._xmllogger.started_output:
            suite.context.output_file_changed(self._xmllogger.started_output)
            if self._namegen:
                suite.context.log_file_changed(self._namegen.get_name())

    def end_suite(self, suite):
        LOGGER.end_suite(suite)
        if self._xmllogger.ended_output:
            LOGGER.output_file('Output', self._xmllogger.ended_output)
            orig_outpath = self._settings['Output']
            suite.context.output_file_changed(orig_outpath)
            self._create_split_log(self._xmllogger.ended_output, suite)

    def _create_split_log(self, outpath, suite):
        if self._namegen is None:
            return
        logpath = self._namegen.get_prev()
        output = robot.serializing.SplitSubTestOutput(outpath)
        output.serialize_log(logpath)
        suite.context.log_file_changed(self._namegen.get_base())

    def start_test(self, test):
        LOGGER.start_test(test)

    def end_test(self, test):
        LOGGER.end_test(test)

    def start_keyword(self, kw):
        LOGGER.start_keyword(kw)

    def end_keyword(self, kw):
        LOGGER.end_keyword(kw)

    def log_output(self, output):
        """Splits given output to levels and messages and logs them"""
        for msg in _OutputSplitter(output):
            self.message(msg)

    def message(self, msg):
        LOGGER.log_message(msg)

    def set_log_level(self, level):
        return self._xmllogger.set_log_level(level)