本文整理汇总了Python中mozlog.commandline.setup_logging函数的典型用法代码示例。如果您正苦于以下问题:Python setup_logging函数的具体用法?Python setup_logging怎么用?Python setup_logging使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setup_logging函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: test_limit_formatters
def test_limit_formatters(self):
parser = argparse.ArgumentParser()
commandline.add_logging_group(parser, include_formatters=['raw'])
other_formatters = [fmt for fmt in commandline.log_formatters
if fmt != 'raw']
# check that every formatter except raw is not present
for fmt in other_formatters:
with self.assertRaises(SystemExit):
parser.parse_args(["--log-%s=-" % fmt])
with self.assertRaises(SystemExit):
parser.parse_args(["--log-%s-level=error" % fmt])
# raw is still ok
args = parser.parse_args(["--log-raw=-"])
logger = commandline.setup_logging("test_setup_logging2", args, {})
self.assertEqual(len(logger.handlers), 1)
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:15,代码来源:test_structured.py
示例17: 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 = parser_remote()
options = 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 = verifyRemoteOptions(parser, options)
log = commandline.setup_logging("Remote XPCShell",
options,
{"tbpl": sys.stdout})
dm_args = {'deviceRoot': options.remoteTestRoot}
if options.deviceIP:
dm_args['host'] = options.deviceIP
dm_args['port'] = options.devicePort
if options.log_tbpl_level == 'debug' or options.log_mach_level == 'debug':
dm_args['logLevel'] = logging.DEBUG
dm = mozdevice.DroidADB(**dm_args)
if options.interactive and not options.testPath:
print >>sys.stderr, "Error: You must specify a test filename in interactive mode!"
sys.exit(1)
if options.xpcshell is None:
options.xpcshell = "xpcshell"
xpcsh = XPCShellRemote(dm, options, log)
# we don't run concurrent tests on mobile
options.sequential = True
if not xpcsh.runTests(testClass=RemoteXPCShellTestThread,
mobileArgs=xpcsh.mobileArgs,
**vars(options)):
sys.exit(1)
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:47,代码来源:remotexpcshelltests.py
示例18: test
def test(self, what, extra_args, **log_args):
"""Run tests from names or paths.
mach test accepts arguments specifying which tests to run. Each argument
can be:
* The path to a test file
* A directory containing tests
* A test suite name
* An alias to a test suite name (codes used on TreeHerder)
If no input is provided, tests will be run based on files changed in
the local tree. Relevant tests, tags, or flavors are determined by
IMPACTED_TESTS annotations in moz.build files relevant to the
changed files.
When paths or directories are given, they are first resolved to test
files known to the build system.
If resolved tests belong to more than one test type/flavor/harness,
the harness for each relevant type/flavor will be invoked. e.g. if
you specify a directory with xpcshell and browser chrome mochitests,
both harnesses will be invoked.
"""
from mozlog.commandline import setup_logging
from moztest.resolve import TestResolver, TEST_FLAVORS, TEST_SUITES
resolver = self._spawn(TestResolver)
run_suites, run_tests = resolver.resolve_metadata(what)
if not run_suites and not run_tests:
print(UNKNOWN_TEST)
return 1
# Create shared logger
default_format = self._mach_context.settings['test']['format']
default_level = self._mach_context.settings['test']['level']
log = setup_logging('mach-test', log_args, {default_format: sys.stdout},
{'level': default_level})
log.handlers[0].formatter.inner.summary_on_shutdown = True
status = None
for suite_name in run_suites:
suite = TEST_SUITES[suite_name]
kwargs = suite['kwargs']
kwargs['log'] = log
if 'mach_command' in suite:
res = self._mach_context.commands.dispatch(
suite['mach_command'], self._mach_context,
argv=extra_args, **kwargs)
if res:
status = res
buckets = {}
for test in run_tests:
key = (test['flavor'], test.get('subsuite', ''))
buckets.setdefault(key, []).append(test)
for (flavor, subsuite), tests in sorted(buckets.items()):
if flavor not in TEST_FLAVORS:
print(UNKNOWN_FLAVOR % flavor)
status = 1
continue
m = TEST_FLAVORS[flavor]
if 'mach_command' not in m:
print(UNKNOWN_FLAVOR % flavor)
status = 1
continue
kwargs = dict(m['kwargs'])
kwargs['log'] = log
kwargs['subsuite'] = subsuite
res = self._mach_context.commands.dispatch(
m['mach_command'], self._mach_context,
argv=extra_args, test_objects=tests, **kwargs)
if res:
status = res
log.shutdown()
return status
开发者ID:luke-chang,项目名称:gecko-1,代码行数:83,代码来源:mach_commands.py
示例19: Exception
'title': 'artifact uploaded'})
j.artifacts.append(('Results', 'json', results))
# TODO - fix this fake log parsing
if log_files:
failures = []
if results.get('total failed'):
failures = ['Total failed: %s' % results['total failed']]
j.parsed_logs[log_files[0]] = failures
if job1.build['repo'] == job2.build['repo']:
treeherder.submit_complete([job1, job2])
else:
# Jobs that belong to different repos cannot be submitted in one
# collection
treeherder.submit_complete([job1])
treeherder.submit_complete([job2])
return result_string
if __name__ == '__main__':
logger = commandline.setup_logging("example-submission", None,
{"mach": sys.stdout},
{"level": "debug"})
result_string = main(sys.argv[1:])
if result_string == 'busted':
raise Exception('Something went wrong in the test harness.')
elif result_string != 'success':
sys.exit(1)
else:
sys.exit(0)
开发者ID:mjzffr,项目名称:treeherder-submission-example,代码行数:29,代码来源:jenkinsherder.py
示例20: test_setup_logging
def test_setup_logging(self):
parser = argparse.ArgumentParser()
commandline.add_logging_group(parser)
args = parser.parse_args(["--log-raw=-"])
logger = commandline.setup_logging("test_setup_logging", args, {})
self.assertEqual(len(logger.handlers), 1)
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:6,代码来源:test_structured.py
注:本文中的mozlog.commandline.setup_logging函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论