コード例 #1
0
def setup_logging(log_f):
    global logger
    logger = structuredlog.StructuredLogger("firefox-os-cert-suite")
    logger.add_handler(stdio_handler)
    logger.add_handler(
        handlers.StreamHandler(log_f, formatters.JSONFormatter()))
    set_default_logger(logger)
コード例 #2
0
def setup_logging(log_f):
    global logger
    logger = structuredlog.StructuredLogger("firefox-os-cert-suite")
    logger.add_handler(
        handlers.StreamHandler(sys.stderr, formatters.MachFormatter()))

    logger.add_handler(
        handlers.StreamHandler(log_f, formatters.JSONFormatter()))
コード例 #3
0
    def run_test(self, suite, groups, temp_dir):
        logger.info('Running suite %s' % suite)

        def on_output(line):
            written = False
            if line.startswith("{"):
                try:
                    data = json.loads(line.strip())
                    if "action" in data:
                        sub_logger.log_raw(data)
                        written = True
                except ValueError:
                    pass
            if not written:
                logger.process_output(proc.pid,
                                      line.decode("utf8", "replace"),
                                      command=" ".join(cmd))

        try:
            cmd, output_files, structured_path = self.build_command(
                suite, groups, temp_dir)

            logger.debug(cmd)
            logger.debug(output_files)

            env = dict(os.environ)
            env['PYTHONUNBUFFERED'] = '1'
            proc = mozprocess.ProcessHandler(cmd,
                                             env=env,
                                             processOutputLine=on_output)
            logger.debug("Process '%s' is running" % " ".join(cmd))
            #TODO: move timeout handling to here instead of each test?
            with open(structured_path, "w") as structured_log:
                sub_logger = structuredlog.StructuredLogger(suite)
                sub_logger.add_handler(stdio_handler)
                sub_logger.add_handler(
                    handlers.StreamHandler(structured_log,
                                           formatters.JSONFormatter()))
                proc.run()
                proc.wait()
            logger.debug("Process finished")

        except Exception:
            logger.error("Error running suite %s:\n%s" %
                         (suite, traceback.format_exc()))
            raise
        finally:
            try:
                proc.kill()
            except:
                pass

        return output_files, structured_path
コード例 #4
0
ファイル: test_update.py プロジェクト: martapiekarska/gecko
    def create_log(self, *args, **kwargs):
        logger = structuredlog.StructuredLogger("expected_test")
        data = StringIO.StringIO()
        handler = handlers.StreamHandler(data, formatters.JSONFormatter())
        logger.add_handler(handler)

        log_entries = ([("suite_start", {
            "tests": [],
            "run_info": kwargs.get("run_info", {})
        })] + list(args) + [("suite_end", {})])

        for item in log_entries:
            action, kwargs = item
            getattr(logger, action)(**kwargs)
        logger.remove_handler(handler)
        data.seek(0)
        return data
コード例 #5
0
ファイル: main.py プロジェクト: luser/fxos-certsuite
def create_logger():
    logger = structuredlog.StructuredLogger("unknown")
    logger.add_handler(
        handlers.StreamHandler(sys.stdout, formatters.JSONFormatter()))
    return logger