本文整理汇总了Python中mozlog.get_default_logger函数的典型用法代码示例。如果您正苦于以下问题:Python get_default_logger函数的具体用法?Python get_default_logger怎么用?Python get_default_logger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_default_logger函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, app_ctx=None, profile=None, clean_profile=True, env=None,
process_class=None, process_args=None, symbols_path=None,
dump_save_path=None, addons=None):
self.app_ctx = app_ctx or DefaultContext()
if isinstance(profile, basestring):
self.profile = self.app_ctx.profile_class(profile=profile,
addons=addons)
else:
self.profile = profile or self.app_ctx.profile_class(**getattr(self.app_ctx,
'profile_args', {}))
self.logger = get_default_logger()
# process environment
if env is None:
self.env = os.environ.copy()
else:
self.env = env.copy()
self.clean_profile = clean_profile
self.process_class = process_class or ProcessHandler
self.process_args = process_args or {}
self.symbols_path = symbols_path
self.dump_save_path = dump_save_path
self.crashed = 0
示例2: kill
def kill(self, stagedShutdown = False):
if self.utilityPath:
# Take a screenshot to capture the screen state just before
# the application is killed. There are on-device screenshot
# options but they rarely work well with Firefox on the
# Android emulator. dump_screen provides an effective
# screenshot of the emulator and its host desktop.
dump_screen(self.utilityPath, get_default_logger())
if stagedShutdown:
# Trigger an ANR report with "kill -3" (SIGQUIT)
self.dm.killProcess(self.procName, 3)
time.sleep(3)
# Trigger a breakpad dump with "kill -6" (SIGABRT)
self.dm.killProcess(self.procName, 6)
# Wait for process to end
retries = 0
while retries < 3:
pid = self.dm.processExist(self.procName)
if pid and pid > 0:
print "%s still alive after SIGABRT: waiting..." % self.procName
time.sleep(5)
else:
return
retries += 1
self.dm.killProcess(self.procName, 9)
pid = self.dm.processExist(self.procName)
if pid and pid > 0:
self.dm.killProcess(self.procName)
else:
self.dm.killProcess(self.procName)
示例3: __init__
def __init__(self, methodName, **kwargs):
unittest.TestCase.__init__(self, methodName)
self.loglines = []
self.duration = 0
self.start_time = 0
self.expected = kwargs.pop('expected', 'pass')
self.logger = get_default_logger()
示例4: run_tests
def run_tests(self, programs, xre_path, symbols_path=None, interactive=False):
"""
Run a set of C++ unit test programs.
Arguments:
* programs: An iterable containing (test path, test timeout factor) tuples
* xre_path: A path to a directory containing a XUL Runtime Environment.
* symbols_path: A path to a directory containing Breakpad-formatted
symbol files for producing stack traces on crash.
Returns True if all test programs exited with a zero status, False
otherwise.
"""
self.xre_path = xre_path
self.log = mozlog.get_default_logger()
self.log.suite_start(programs)
env = self.build_environment()
pass_count = 0
fail_count = 0
for prog in programs:
test_path = prog[0]
timeout_factor = prog[1]
single_result = self.run_one_test(test_path, env, symbols_path,
interactive, timeout_factor)
if single_result:
pass_count += 1
else:
fail_count += 1
self.log.suite_end()
# Mozharness-parseable summary formatting.
self.log.info("Result summary:")
self.log.info("cppunittests INFO | Passed: %d" % pass_count)
self.log.info("cppunittests INFO | Failed: %d" % fail_count)
return fail_count == 0
示例5: inner
def inner(command, *args, **kwargs):
global logger
if logger is None:
logger = get_default_logger("vcs")
repo = kwargs.pop("repo", None)
log_error = kwargs.pop("log_error", True)
if kwargs:
raise TypeError, kwargs
args = list(args)
proc_kwargs = {}
if repo is not None:
proc_kwargs["cwd"] = repo
command_line = [bin_name, command] + args
logger.debug(" ".join(command_line))
try:
return subprocess.check_output(command_line, stderr=subprocess.STDOUT, **proc_kwargs)
except subprocess.CalledProcessError as e:
if log_error:
logger.error(e.output)
raise
示例6: start
def start(self, debug_args=None, interactive=False, timeout=None, outputTimeout=None):
"""
Run self.command in the proper environment.
:param debug_args: arguments for a debugger
:param interactive: uses subprocess.Popen directly
:param timeout: see process_handler.run()
:param outputTimeout: see process_handler.run()
:returns: the process id
"""
self.timeout = timeout
self.output_timeout = outputTimeout
cmd = self.command
# ensure the runner is stopped
self.stop()
# attach a debugger, if specified
if debug_args:
cmd = list(debug_args) + cmd
logger = get_default_logger()
if logger:
logger.info('Application command: %s' % ' '.join(cmd))
if interactive:
self.process_handler = subprocess.Popen(cmd, env=self.env)
# TODO: other arguments
else:
# this run uses the managed processhandler
self.process_handler = self.process_class(cmd, env=self.env, **self.process_args)
self.process_handler.run(self.timeout, self.output_timeout)
self.crashed = 0
return self.process_handler.pid
示例7: check_for_crashes
def check_for_crashes(self, dump_directory=None, dump_save_path=None, test_name=None, quiet=False):
"""
Check for a possible crash and output stack trace.
:param dump_directory: Directory to search for minidump files
:param dump_save_path: Directory to save the minidump files to
:param test_name: Name to use in the crash output
:param quiet: If `True` don't print the PROCESS-CRASH message to stdout
:returns: True if a crash was detected, otherwise False
"""
if not dump_directory:
dump_directory = os.path.join(self.profile.profile, "minidumps")
if not dump_save_path:
dump_save_path = self.dump_save_path
try:
logger = get_default_logger()
if logger is not None:
if test_name is None:
test_name = "runner.py"
self.crashed += mozcrash.log_crashes(
logger, dump_directory, self.symbols_path, dump_save_path=dump_save_path, test=test_name
)
else:
crashed = mozcrash.check_for_crashes(
dump_directory, self.symbols_path, dump_save_path=dump_save_path, test_name=test_name, quiet=quiet
)
if crashed:
self.crashed += 1
except:
traceback.print_exc()
return self.crashed
示例8: _get_default_logger
def _get_default_logger():
from mozlog import get_default_logger
log = get_default_logger(component='mozleak')
if not log:
import logging
log = logging.getLogger(__name__)
return log
示例9: __init__
def __init__(self, methodName, **kwargs):
unittest.TestCase.__init__(self, methodName)
self.loglines = []
self.duration = 0
self.expected = kwargs.pop("expected", "pass")
self.logger = get_default_logger()
self.profile = FirefoxProfile()
self.binary = kwargs.pop("binary", None)
示例10: kill
def kill(self, stagedShutdown=False):
# Take a screenshot to capture the screen state just before
# the application is killed.
if not self.device._device_serial.startswith('emulator-'):
dump_device_screen(self.device, get_default_logger())
elif self.utilityPath:
# Do not use the on-device screenshot options since
# they rarely work well with Firefox on the Android
# emulator. dump_screen provides an effective
# screenshot of the emulator and its host desktop.
dump_screen(self.utilityPath, get_default_logger())
if stagedShutdown:
# Trigger an ANR report with "kill -3" (SIGQUIT)
try:
self.device.pkill(self.procName, sig=3, attempts=1)
except ADBTimeoutError:
raise
except: # NOQA: E722
pass
time.sleep(3)
# Trigger a breakpad dump with "kill -6" (SIGABRT)
try:
self.device.pkill(self.procName, sig=6, attempts=1)
except ADBTimeoutError:
raise
except: # NOQA: E722
pass
# Wait for process to end
retries = 0
while retries < 3:
if self.device.process_exist(self.procName):
print("%s still alive after SIGABRT: waiting..." % self.procName)
time.sleep(5)
else:
return
retries += 1
try:
self.device.pkill(self.procName, sig=9, attempts=1)
except ADBTimeoutError:
raise
except: # NOQA: E722
print("%s still alive after SIGKILL!" % self.procName)
if self.device.process_exist(self.procName):
self.device.stop_application(self.procName)
else:
self.device.stop_application(self.procName)
示例11: test_process_output_enabled
def test_process_output_enabled(args, enabled):
do_cli(*args)
log_filter = get_default_logger("process").component_filter
result = log_filter({"some": "data"})
if enabled:
assert result
else:
assert not result
示例12: test_mozversion_output_filtered
def test_mozversion_output_filtered(mozversion_msg, shown):
do_cli()
log_filter = get_default_logger("mozversion").component_filter
log_data = {"message": mozversion_msg}
result = log_filter(log_data)
if shown:
assert result == log_data
else:
assert not result
示例13: log
def log(text, log=True, status_bar=True, status_bar_timeout=2.0):
if log:
logger = get_default_logger('mozregui')
if logger:
logger.info(text)
if status_bar:
from mozregui.mainwindow import MainWindow
mw = MainWindow.INSTANCE
if mw:
mw.ui.status_bar.showMessage(text, int(status_bar_timeout * 1000))
示例14: __init__
def __init__(self, methodName, marionette_weakref, fixtures, **kwargs):
super(CommonTestCase, self).__init__(methodName)
self.methodName = methodName
self._marionette_weakref = marionette_weakref
self.fixtures = fixtures
self.duration = 0
self.start_time = 0
self.expected = kwargs.pop('expected', 'pass')
self.logger = get_default_logger()
示例15: gather_media_debug
def gather_media_debug(test, status):
rv = {}
marionette = test._marionette_weakref()
if marionette.session is not None:
try:
with marionette.using_context(marionette.CONTEXT_CHROME):
debug_lines = marionette.execute_script(debug_script)
if debug_lines:
name = 'mozMediaSourceObject.mozDebugReaderData'
rv[name] = '\n'.join(debug_lines)
else:
logger = mozlog.get_default_logger()
logger.info('No data available about '
'mozMediaSourceObject')
except:
logger = mozlog.get_default_logger()
logger.warning('Failed to gather test failure media debug',
exc_info=True)
return rv