当前位置: 首页>>代码示例>>Python>>正文


Python commandline.setup_logging函数代码示例

本文整理汇总了Python中mozlog.commandline.setup_logging函数的典型用法代码示例。如果您正苦于以下问题:Python setup_logging函数的具体用法?Python setup_logging怎么用?Python setup_logging使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了setup_logging函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _lint

 def _lint(self, files, linter, **lintargs):
     payload = linter["payload"]
     handler = LintHandler(linter)
     logger = linter.get("logger")
     if logger is None:
         logger = get_default_logger()
     if logger is None:
         logger = structuredlog.StructuredLogger(linter["name"])
         commandline.setup_logging(logger, {}, {"mach": sys.stdout})
     logger.add_handler(handler)
     try:
         payload(files, logger, **lintargs)
     except KeyboardInterrupt:
         pass
     return handler.results
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:15,代码来源:types.py

示例2: test_setup_logging_optparse

 def test_setup_logging_optparse(self):
     parser = optparse.OptionParser()
     commandline.add_logging_group(parser)
     args, _ = parser.parse_args(["--log-raw=-"])
     logger = commandline.setup_logging("test_optparse", args, {})
     self.assertEqual(len(logger.handlers), 1)
     self.assertIsInstance(logger.handlers[0], handlers.StreamHandler)
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:7,代码来源:test_structured.py

示例3: run_mochitest

def run_mochitest(context, **kwargs):
    from mochitest_options import ALL_FLAVORS
    from mozlog.commandline import setup_logging

    if not kwargs.get('log'):
        kwargs['log'] = setup_logging('mochitest', kwargs, {'mach': sys.stdout})

    flavor = kwargs.get('flavor') or 'mochitest'
    if flavor not in ALL_FLAVORS:
        for fname, fobj in ALL_FLAVORS.iteritems():
            if flavor in fobj['aliases']:
                flavor = fname
                break
    fobj = ALL_FLAVORS[flavor]
    kwargs.update(fobj.get('extra_args', {}))

    args = Namespace(**kwargs)
    args.e10s = context.mozharness_config.get('e10s', args.e10s)
    args.certPath = context.certs_dir

    if args.test_paths:
        install_subdir = fobj.get('install_subdir', fobj['suite'])
        test_root = os.path.join(context.package_root, 'mochitest', install_subdir)
        normalize = partial(context.normalize_test_path, test_root)
        args.test_paths = map(normalize, args.test_paths)

    import mozinfo
    if mozinfo.info.get('buildapp') == 'mobile/android':
        return run_mochitest_android(context, args)
    return run_mochitest_desktop(context, args)
开发者ID:luke-chang,项目名称:gecko-1,代码行数:30,代码来源:mach_test_package_commands.py

示例4: main

def main():
    parser = parser_b2g()
    options = parser.parse_args()
    log = commandline.setup_logging("Remote XPCShell",
                                    options,
                                    {"tbpl": sys.stdout})
    run_remote_xpcshell(parser, options, log)
开发者ID:MekliCZ,项目名称:positron,代码行数:7,代码来源:runtestsb2g.py

示例5: run_cppunit_test

    def run_cppunit_test(self, **params):
        import mozinfo
        from mozlog import commandline
        import runcppunittests as cppunittests

        log = commandline.setup_logging("cppunittest",
                                        {},
                                        {"tbpl": sys.stdout})

        if len(params['test_files']) == 0:
            testdir = os.path.join(self.distdir, 'cppunittests')
            manifest = os.path.join(self.topsrcdir, 'testing', 'cppunittest.ini')
            tests = cppunittests.extract_unittests_from_args([testdir], mozinfo.info, manifest)
        else:
            tests = cppunittests.extract_unittests_from_args(params['test_files'], mozinfo.info, None)

        # See if we have crash symbols
        symbols_path = os.path.join(self.distdir, 'crashreporter-symbols')
        if not os.path.isdir(symbols_path):
            symbols_path = None

        tester = cppunittests.CPPUnitTests()
        try:
            result = tester.run_tests(tests, self.bindir, symbols_path, interactive=True)
        except Exception as e:
            log.error("Caught exception running cpp unit tests: %s" % str(e))
            result = False

        return 0 if result else 1
开发者ID:sumitbh250,项目名称:gecko-dev,代码行数:29,代码来源:mach_commands.py

示例6: _lint

    def _lint(self, files, config, **lintargs):
        handler = LintHandler(config)
        logger = config.get("logger")
        if logger is None:
            logger = get_default_logger()
        if logger is None:
            logger = structuredlog.StructuredLogger(config["name"])
            commandline.setup_logging(logger, {}, {"mach": sys.stdout})
        logger.add_handler(handler)

        func = findobject(config["payload"])
        try:
            func(files, config, logger, **lintargs)
        except KeyboardInterrupt:
            pass
        return handler.results
开发者ID:mykmelez,项目名称:spidernode,代码行数:16,代码来源:types.py

示例7: main

def main():
    parser = B2GOptions()
    commandline.add_logging_group(parser)
    options, args = parser.parse_args()
    log = commandline.setup_logging("Remote XPCShell",
                                    options,
                                    {"tbpl": sys.stdout})
    run_remote_xpcshell(parser, options, args, log)
开发者ID:paulmadore,项目名称:luckyde,代码行数:8,代码来源:runtestsb2g.py

示例8: setup

def setup(args, defaults):
    logger = commandline.setup_logging("web-platform-tests", args, defaults)
    setup_stdlib_logger()

    for name in args.keys():
        if name.startswith("log_"):
            args.pop(name)

    return logger
开发者ID:EdgarChen,项目名称:web-platform-tests,代码行数:9,代码来源:wptlogging.py

示例9: main

def main():

    if sys.version_info < (2,7):
        print >>sys.stderr, "Error: You must use python version 2.7 or newer but less than 3.0"
        sys.exit(1)

    parser = RemoteXPCShellOptions()
    commandline.add_logging_group(parser)
    options, args = parser.parse_args()
    if not options.localAPK:
        for file in os.listdir(os.path.join(options.objdir, "dist")):
            if (file.endswith(".apk") and file.startswith("fennec")):
                options.localAPK = os.path.join(options.objdir, "dist")
                options.localAPK = os.path.join(options.localAPK, file)
                print >>sys.stderr, "using APK: " + options.localAPK
                break
        else:
            print >>sys.stderr, "Error: please specify an APK"
            sys.exit(1)

    options = parser.verifyRemoteOptions(options)
    log = commandline.setup_logging("Remote XPCShell",
                                    options,
                                    {"tbpl": sys.stdout})

    if len(args) < 1 and options.manifest is None:
        print >>sys.stderr, """Usage: %s <test dirs>
             or: %s --manifest=test.manifest """ % (sys.argv[0], sys.argv[0])
        sys.exit(1)

    if options.dm_trans == "adb":
        if options.deviceIP:
            dm = mozdevice.DroidADB(options.deviceIP, options.devicePort, packageName=None, deviceRoot=options.remoteTestRoot)
        else:
            dm = mozdevice.DroidADB(packageName=None, deviceRoot=options.remoteTestRoot)
    else:
        if not options.deviceIP:
            print "Error: you must provide a device IP to connect to via the --device option"
            sys.exit(1)
        dm = mozdevice.DroidSUT(options.deviceIP, options.devicePort, deviceRoot=options.remoteTestRoot)

    if options.interactive and not options.testPath:
        print >>sys.stderr, "Error: You must specify a test filename in interactive mode!"
        sys.exit(1)

    xpcsh = XPCShellRemote(dm, options, args, log)

    # we don't run concurrent tests on mobile
    options.sequential = True

    if not xpcsh.runTests(xpcshell='xpcshell',
                          testClass=RemoteXPCShellTestThread,
                          testdirs=args[0:],
                          mobileArgs=xpcsh.mobileArgs,
                          **options.__dict__):
        sys.exit(1)
开发者ID:rthyberg,项目名称:gecko-dev,代码行数:56,代码来源:remotexpcshelltests.py

示例10: setup_logging

def setup_logging(args, defaults):
    global logger
    logger = commandline.setup_logging("web-platform-tests-unstable", args, defaults)
    wptrunner.setup_stdlib_logger()

    for name in args.keys():
        if name.startswith("log_"):
            args.pop(name)

    return logger
开发者ID:ConnorGBrewster,项目名称:servo,代码行数:10,代码来源:reduce.py

示例11: test_logging_errorlevel

    def test_logging_errorlevel(self):
        parser = argparse.ArgumentParser()
        commandline.add_logging_group(parser)
        args = parser.parse_args(["--log-tbpl=%s" % self.logfile.name, "--log-tbpl-level=error"])
        logger = commandline.setup_logging("test_fmtopts", args, {})
        logger.info("INFO message")
        logger.debug("DEBUG message")
        logger.error("ERROR message")

        # Only the error level and above were requested.
        self.assertEqual(["ERROR message"],
                         self.loglines)
开发者ID:hoosteeno,项目名称:gecko-dev,代码行数:12,代码来源:test_structured.py

示例12: main

def main():
    parser = get_parser()
    commandline.add_logging_group(parser)

    args = parser.parse_args()

    logger = commandline.setup_logging("structured-example", args, {"raw": sys.stdout})

    runner = TestRunner()
    try:
        runner.run()
    except Exception:
        logger.critical("Error during test run:\n%s" % traceback.format_exc())
开发者ID:luke-chang,项目名称:gecko-1,代码行数:13,代码来源:structured_example.py

示例13: test_logging_debuglevel

 def test_logging_debuglevel(self):
     parser = argparse.ArgumentParser()
     commandline.add_logging_group(parser)
     args = parser.parse_args(["--log-tbpl=%s" % self.logfile.name, "--log-tbpl-level=debug"])
     logger = commandline.setup_logging("test_fmtopts", args, {})
     logger.info("INFO message")
     logger.debug("DEBUG message")
     logger.error("ERROR message")
     # Requesting a lower log level than default works as expected.
     self.assertEqual(["INFO message",
                       "DEBUG message",
                       "ERROR message"],
                      self.loglines)
开发者ID:hoosteeno,项目名称:gecko-dev,代码行数:13,代码来源:test_structured.py

示例14: test_logging_defaultlevel

    def test_logging_defaultlevel(self):
        parser = argparse.ArgumentParser()
        commandline.add_logging_group(parser)

        args = parser.parse_args(["--log-tbpl=%s" % self.logfile.name])
        logger = commandline.setup_logging("test_fmtopts", args, {})
        logger.info("INFO message")
        logger.debug("DEBUG message")
        logger.error("ERROR message")
        # The debug level is not logged by default.
        self.assertEqual(["INFO message",
                          "ERROR message"],
                         self.loglines)
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:13,代码来源:test_structured.py

示例15: setup

def setup(args, defaults):
    logger = args.pop('log', None)
    if logger:
        set_default_logger(logger)
        StructuredLogger._logger_states["web-platform-tests"] = logger._state
    else:
        logger = commandline.setup_logging("web-platform-tests", args, defaults)
    setup_stdlib_logger()

    for name in args.keys():
        if name.startswith("log_"):
            args.pop(name)

    return logger
开发者ID:Coder206,项目名称:servo,代码行数:14,代码来源:wptlogging.py


注:本文中的mozlog.commandline.setup_logging函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。