本文整理汇总了Python中mozlog.getLogger函数的典型用法代码示例。如果您正苦于以下问题:Python getLogger函数的具体用法?Python getLogger怎么用?Python getLogger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getLogger函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main(args=sys.argv[1:]):
"""
Return codes
0 - success
1 - test failures
2 - fatal error
"""
parser = PeptestOptions()
options, args = parser.parse_args()
options = parser.verifyOptions(options)
if options == None:
return 2
# setup the logging
if options.logFile:
handler = mozlog.FileHandler(options.logFile)
handler.setFormatter(mozlog.MozFormatter())
logger = mozlog.getLogger('PEP', handler)
else:
logger = mozlog.getLogger('PEP')
if options.logLevel:
logger.setLevel(getattr(mozlog, options.logLevel, 'INFO'))
try:
peptest = applications[options.app](options)
return peptest.start()
except Exception:
cla, exc = sys.exc_info()[:2]
logger.error("%s: %s" % (cla.__name__, exc))
logger.debug("Traceback:\n%s" % (traceback.format_exc()))
return 2
开发者ID:mozilla,项目名称:peptest,代码行数:32,代码来源:runpeptests.py
示例2: test_logger_defaults
def test_logger_defaults(self):
"""Tests the default logging format and behavior."""
default_logger = mozlog.getLogger("default.logger")
self.assertEqual(default_logger.name, "default.logger")
self.assertEqual(len(default_logger.handlers), 1)
self.assertTrue(isinstance(default_logger.handlers[0], mozlog.StreamHandler))
f = mozfile.NamedTemporaryFile()
list_logger = mozlog.getLogger("file.logger", handler=mozlog.FileHandler(f.name))
self.assertEqual(len(list_logger.handlers), 1)
self.assertTrue(isinstance(list_logger.handlers[0], mozlog.FileHandler))
f.close()
self.assertRaises(ValueError, mozlog.getLogger, "file.logger", handler=ListHandler())
开发者ID:jpetrell,项目名称:gecko-dev,代码行数:15,代码来源:test_logger.py
示例3: cli
def cli():
parser = OptionParser(usage='%prog [options] <test_file> <test_file> ...')
parser.add_option("--binary",
action="store", dest="binary",
default=None,
help="path to B2G desktop build binary")
parser.add_option("--profile",
action="store", dest="profile",
default=None,
help="path to gaia profile directory")
options, tests = parser.parse_args()
if not options.binary or not options.profile:
parser.print_usage()
parser.exit('--binary and --profile required')
if not tests:
# Read in a list of tests to skip from disabled.json, if it exists;
# disabled.json should contain filenames with paths relative to the
# apps directory, e.g., "wallpaper/test/unit/pick_test.js".
disabled = []
disabled_file = os.path.join(os.path.dirname(__file__), 'disabled.json')
if os.access(disabled_file, os.F_OK):
with open(disabled_file, 'r') as f:
disabled_contents = f.read()
try:
disabled = json.loads(disabled_contents)
except:
traceback.print_exc()
print "Error while decoding disabled.json; please make sure this file has valid JSON syntax."
sys.exit(1)
# build a list of tests
appsdir = os.path.join(os.path.dirname(os.path.abspath(options.profile)), 'apps')
for root, dirs, files in os.walk(appsdir):
for file in files:
full_path = os.path.relpath(os.path.join(root, file), appsdir)
if full_path[-8:] == '_test.js' and full_path not in disabled:
tests.append(full_path)
runner = GaiaUnitTestRunner(binary=options.binary,
profile=options.profile)
runner.run()
# Lame but necessary hack to prevent tornado's logger from duplicating
# every message from mozlog.
logger = logging.getLogger()
handler = logging.NullHandler()
logger.addHandler(handler)
print 'starting WebSocket Server'
application = tornado.web.Application([
(r"/", TestAgentServer, {'tests': tests,
'runner': runner,
'logger': mozlog.getLogger('gaia-unit-tests')}),
])
http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(8789)
tornado.ioloop.IOLoop.instance().start()
开发者ID:Drmikej,项目名称:gaia,代码行数:60,代码来源:main.py
示例4: __init__
def __init__(self, device_serial=None):
self.device_serial = device_serial
self._logger = structured.get_default_logger(component='b2gmonkey')
if not self._logger:
self._logger = mozlog.getLogger('b2gmonkey')
self.version = mozversion.get_version(
dm_type='adb', device_serial=device_serial)
device_id = self.version.get('device_id')
if not device_id:
raise B2GMonkeyError('Firefox OS device not found.')
self.device_properties = DEVICE_PROPERTIES.get(device_id)
if not self.device_properties:
raise B2GMonkeyError('Unsupported device: \'%s\'' % device_id)
android_version = self.version.get('device_firmware_version_release')
if device_id == 'flame' and android_version == '4.4.2':
self.device_properties.update(DEVICE_PROPERTIES.get('flame-kk'))
self.temp_dir = tempfile.mkdtemp()
if 'MINIDUMP_SAVE_PATH' not in os.environ:
self.crash_dumps_path = os.path.join(self.temp_dir, 'crashes')
os.environ['MINIDUMP_SAVE_PATH'] = self.crash_dumps_path
else:
self.crash_dumps_path = os.environ['MINIDUMP_SAVE_PATH']
开发者ID:JJTC-PX,项目名称:b2gmonkey,代码行数:28,代码来源:b2gmonkey.py
示例5: gather_debug
def gather_debug(test, status):
rv = {}
marionette = test._marionette_weakref()
# In the event we're gathering debug without starting a session, skip marionette commands
if marionette.session is not None:
try:
marionette.switch_to_frame()
rv["settings"] = json.dumps(
marionette.execute_async_script(
"""
SpecialPowers.pushPermissions([
{type: 'settings-read', allow: true, context: document},
{type: 'settings-api-read', allow: true, context: document},
], function() {
var req = window.navigator.mozSettings.createLock().get('*');
req.onsuccess = function() {
marionetteScriptFinished(req.result);
}
});""",
special_powers=True,
),
sort_keys=True,
indent=4,
separators=(",", ": "),
)
except:
logger = mozlog.structured.get_default_logger()
if not logger:
logger = mozlog.getLogger("gaiatest")
logger.warning("Failed to gather test failure debug.", exc_info=True)
return rv
开发者ID:hharchani,项目名称:gaia,代码行数:32,代码来源:runtests.py
示例6: __init__
def __init__(self, tests, testfile=None,
es_server=None, rest_server=None, testgroup='marionette'):
self.logger = mozlog.getLogger('B2G_AUTOMATION')
self.tests = tests
self.testfile = testfile
self.es_server = es_server
self.rest_server = rest_server
self.testgroup = testgroup
self.lock = RLock()
self.logger.info("Testlist: %s" % self.tests)
pulse = B2GPulseConsumer(applabel='b2g_build_listener')
pulse.configure(topic='#', callback=self.on_build)
if not self.testfile:
self.logger.info('waiting for pulse messages...')
pulse.listen()
else:
t = Thread(target=pulse.listen)
t.daemon = True
t.start()
f = open(self.testfile, 'r')
data = json.loads(f.read())
self.on_build(data, None)
开发者ID:AshishNamdev,项目名称:mozilla-central,代码行数:25,代码来源:automator.py
示例7: __init__
def __init__(self, **kwargs):
# Set up the log file or use stdout if none specified
self.log = mozlog.getLogger('FB_UPDATE', kwargs.get('log'))
self.log.setLevel(mozlog.DEBUG if kwargs.get('debug') else mozlog.INFO)
self.repo = kwargs.get('repo')
self.serverpath = kwargs.get('serverpath')
开发者ID:ahal,项目名称:Firebug-Test-Runner,代码行数:7,代码来源:fb_update.py
示例8: __init__
def __init__(self, marionette, datazilla_config=None, sources=None,
log_level='INFO'):
# Set up logging
handler = mozlog.StreamHandler()
handler.setFormatter(mozlog.MozFormatter(include_timestamp=True))
self.logger = mozlog.getLogger(self.__class__.__name__, handler)
self.logger.setLevel(getattr(mozlog, log_level.upper()))
self.marionette = marionette
settings = gaiatest.GaiaData(self.marionette).all_settings
mac_address = self.marionette.execute_script(
'return navigator.mozWifiManager && '
'navigator.mozWifiManager.macAddress;')
self.submit_report = True
self.ancillary_data = {}
self.ancillary_data['generated_by'] = 'b2gperf %s' % __version__
self.device = gaiatest.GaiaDevice(self.marionette)
dm = mozdevice.DeviceManagerADB()
self.device.add_device_manager(dm)
version = mozversion.get_version(sources=sources, dm_type='adb')
self.ancillary_data['build_revision'] = version.get('build_changeset')
self.ancillary_data['gaia_revision'] = version.get('gaia_changeset')
self.ancillary_data['gecko_revision'] = version.get('gecko_changeset')
self.ancillary_data['ro.build.version.incremental'] = version.get(
'device_firmware_version_incremental')
self.ancillary_data['ro.build.version.release'] = version.get(
'device_firmware_version_release')
self.ancillary_data['ro.build.date.utc'] = version.get(
'device_firmware_date')
self.required = {
'generated by': self.ancillary_data.get('generated_by'),
'gaia revision': self.ancillary_data.get('gaia_revision'),
'gecko revision': self.ancillary_data.get('gecko_revision'),
'build revision': self.ancillary_data.get('build_revision'),
'protocol': datazilla_config['protocol'],
'host': datazilla_config['host'],
'project': datazilla_config['project'],
'branch': datazilla_config['branch'],
'oauth key': datazilla_config['oauth_key'],
'oauth secret': datazilla_config['oauth_secret'],
'machine name': datazilla_config['machine_name'] or mac_address,
'device name': datazilla_config['device_name'],
'os version': settings.get('deviceinfo.os'),
'id': settings.get('deviceinfo.platform_build_id')}
for key, value in self.required.items():
if value:
self.logger.debug('DataZilla field: %s (%s)' % (key, value))
if not value:
self.submit_report = False
self.logger.warn('Missing required DataZilla field: %s' % key)
if not self.submit_report:
self.logger.info('Reports will not be submitted to DataZilla')
开发者ID:jonallengriffin,项目名称:b2gperf,代码行数:59,代码来源:b2gperf.py
示例9: __init__
def __init__(self, profile, clean_profile=True, process_class=None, kp_kwargs=None, env=None):
self.clean_profile = clean_profile
self.env = env or {}
self.kp_kwargs = kp_kwargs or {}
self.process_class = process_class or ProcessHandler
self.process_handler = None
self.profile = profile
self.log = mozlog.getLogger('MozRunner')
开发者ID:AutomatedTester,项目名称:mozbase,代码行数:8,代码来源:runner.py
示例10: main
def main():
parser = OptionParser(usage="%prog <options>")
parser.add_option("--offline", action="store_true", dest="offline", default=False, help="Start without using pulse")
parser.add_option(
"--test-manifest",
action="store",
dest="testmanifest",
default=os.path.join("tests", "all-tests.ini"),
help="Specify the test manifest, defaults to tests/all-tests.ini",
)
parser.add_option(
"--log-file",
action="store",
dest="logfile",
default="b2gautomation.log",
help="Log file to store results, defaults to b2gautomation.log",
)
LOG_LEVELS = ("DEBUG", "INFO", "WARNING", "ERROR")
LEVEL_STRING = ", ".join(LOG_LEVELS)
parser.add_option(
"--log-level",
action="store",
type="choice",
dest="loglevel",
default="DEBUG",
choices=LOG_LEVELS,
help="One of %s for logging level, defaults to debug" % LEVEL_STRING,
)
options, args = parser.parse_args()
if not options.testmanifest:
parser.print_usage()
parser.exit()
if not os.path.exists(options.testmanifest):
print "Could not find manifest file: %s" % options.testmanifest
parser.print_usage()
parser.exit()
# Set up the logger
if os.path.exists(options.logfile):
os.remove(options.logfile)
logger = mozlog.getLogger("B2G_AUTOMATION", options.logfile)
if options.loglevel:
logger.setLevel(getattr(mozlog, options.loglevel, "DEBUG"))
try:
b2gauto = B2GAutomation(options.testmanifest, offline=options.offline)
# this is test code
d = b2gauto.install_build("http://10.242.30.20/out/qemu_package.tar.gz")
b2gauto.run_marionette(d)
except:
s = traceback.format_exc()
logger.error(s)
return 1
return 0
开发者ID:ctalbert,项目名称:marionette_client,代码行数:58,代码来源:automator.py
示例11: setUp
def setUp(self):
self.logger = mozlog.getLogger('mozprofile.addons')
self.logger.setLevel(mozlog.ERROR)
self.profile = mozprofile.profile.Profile()
self.am = self.profile.addon_manager
self.profile_path = self.profile.profile
self.tmpdir = tempfile.mkdtemp()
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:9,代码来源:test_addons.py
示例12: __init__
def __init__(self, options, **kwargs):
self.options = options
self.server = None
self.logger = mozlog.getLogger('PEP')
# create the profile
self.profile = self.profile_class(profile=self.options.profilePath,
addons=[os.path.join(here, 'extension')])
# fork a server to serve the test related files
if self.options.serverPath:
self.runServer()
tests = []
# TODO is there a better way of doing this?
if self.options.testPath.endswith('.js'):
# a single test file was passed in
testObj = {}
testObj['path'] = os.path.realpath(self.options.testPath)
testObj['name'] = os.path.basename(self.options.testPath)
tests.append(testObj)
else:
# a test manifest was passed in
# open and convert the manifest to json
manifest = TestManifest()
manifest.read(self.options.testPath)
tests = manifest.get()
# create a manifest object to be read by the JS side
manifestObj = {}
manifestObj['tests'] = tests
# write manifest to a JSON file
jsonManifest = open(os.path.join(here, 'manifest.json'), 'w')
jsonManifest.write(str(manifestObj).replace("'", "\""))
jsonManifest.close()
# setup environment
env = os.environ.copy()
env['MOZ_INSTRUMENT_EVENT_LOOP'] = '1'
env['MOZ_INSTRUMENT_EVENT_LOOP_THRESHOLD'] = str(options.tracerThreshold)
env['MOZ_INSTRUMENT_EVENT_LOOP_INTERVAL'] = str(options.tracerInterval)
env['MOZ_CRASHREPORTER_NO_REPORT'] = '1'
# construct the browser arguments
cmdargs = []
# TODO Make browserArgs a list
cmdargs.extend(self.options.browserArgs)
cmdargs.extend(['-pep-start', os.path.realpath(jsonManifest.name)])
# run with managed process handler
self.runner = self.runner_class(profile=self.profile,
binary=self.options.binary,
cmdargs=cmdargs,
env=env,
process_class=PepProcess)
开发者ID:vingtetun,项目名称:mozilla-central,代码行数:56,代码来源:runpeptests.py
示例13: setUp
def setUp(self):
self.handler = ListHandler()
self.handler.setFormatter(mozlog.JSONFormatter())
self.logger = mozlog.getLogger('test.Logger')
# Prevents tests from producing output via a default handler.
for h in self.logger.handlers:
self.logger.removeHandler(h)
self.logger.addHandler(self.handler)
self.logger.setLevel(mozlog.DEBUG)
开发者ID:nodeless,项目名称:mozbase,代码行数:10,代码来源:test_logger.py
示例14: __init__
def __init__(self, cmd,
args=None, cwd=None,
env=os.environ.copy(),
ignore_children=False,
**kwargs):
ProcessHandler.__init__(self, cmd, args=args, cwd=cwd, env=env,
ignore_children=ignore_children, **kwargs)
self.logger = mozlog.getLogger('PEP')
开发者ID:gayomard,项目名称:peptest,代码行数:10,代码来源:pepprocess.py
示例15: __init__
def __init__(self, profile, clean_profile=True, process_class=None, kp_kwargs=None, env=None, symbols_path=None):
self.clean_profile = clean_profile
self.env = env or {}
self.kp_kwargs = kp_kwargs or {}
self.process_class = process_class or ProcessHandler
self.process_handler = None
self.returncode = None
self.profile = profile
self.log = mozlog.getLogger("MozRunner")
self.symbols_path = symbols_path
开发者ID:davehunt,项目名称:mozbase,代码行数:10,代码来源:base.py
示例16: set_logger
def set_logger(self, logger_instance=None, name=None):
"""Method for setting the underlying logger instance to be used."""
if logger_instance and not isinstance(logger_instance, mozlog.Logger):
raise ValueError("logger_instance must be an instance of" +
"mozlog.Logger")
if name is None:
name = ".".join([self.__module__, self.__class__.__name__])
self._logger = logger_instance or mozlog.getLogger(name)
开发者ID:AlanWasTaken,项目名称:servo,代码行数:11,代码来源:loggingmixin.py
示例17: __init__
def __init__(self, marionette, datazilla_config=None, sources=None, log_level="INFO"):
# Set up logging
handler = mozlog.StreamHandler()
handler.setFormatter(mozlog.MozFormatter(include_timestamp=True))
self.logger = mozlog.getLogger(self.__class__.__name__, handler)
self.logger.setLevel(getattr(mozlog, log_level.upper()))
self.marionette = marionette
settings = gaiatest.GaiaData(self.marionette).all_settings
mac_address = self.marionette.execute_script(
"return navigator.mozWifiManager && " "navigator.mozWifiManager.macAddress;"
)
self.submit_report = True
self.ancillary_data = {}
self.device = gaiatest.GaiaDevice(self.marionette)
dm = mozdevice.DeviceManagerADB()
self.device.add_device_manager(dm)
version = mozversion.get_version(sources=sources, dm_type="adb")
self.ancillary_data["build_revision"] = version.get("build_changeset")
self.ancillary_data["gaia_revision"] = version.get("gaia_changeset")
self.ancillary_data["gecko_revision"] = version.get("gecko_changeset")
self.ancillary_data["ro.build.version.incremental"] = version.get("device_firmware_version_incremental")
self.ancillary_data["ro.build.version.release"] = version.get("device_firmware_version_release")
self.ancillary_data["ro.build.date.utc"] = version.get("device_firmware_date")
self.required = {
"gaia revision": self.ancillary_data.get("gaia_revision"),
"gecko revision": self.ancillary_data.get("gecko_revision"),
"build revision": self.ancillary_data.get("build_revision"),
"protocol": datazilla_config["protocol"],
"host": datazilla_config["host"],
"project": datazilla_config["project"],
"branch": datazilla_config["branch"],
"oauth key": datazilla_config["oauth_key"],
"oauth secret": datazilla_config["oauth_secret"],
"machine name": datazilla_config["machine_name"] or mac_address,
"device name": datazilla_config["device_name"],
"os version": settings.get("deviceinfo.os"),
"id": settings.get("deviceinfo.platform_build_id"),
}
for key, value in self.required.items():
if value:
self.logger.debug("DataZilla field: %s (%s)" % (key, value))
if not value:
self.submit_report = False
self.logger.warn("Missing required DataZilla field: %s" % key)
if not self.submit_report:
self.logger.info("Reports will not be submitted to DataZilla")
开发者ID:rwood-moz,项目名称:b2gperf,代码行数:53,代码来源:b2gperf.py
示例18: test_timestamps
def test_timestamps(self):
"""Verifies that timestamps are included when asked for."""
log_name = 'test'
handler = ListHandler()
handler.setFormatter(mozlog.MozFormatter())
log = mozlog.getLogger(log_name, handler=handler)
log.info('no timestamp')
self.assertTrue(handler.messages[-1].startswith('%s ' % log_name))
handler.setFormatter(mozlog.MozFormatter(include_timestamp=True))
log.info('timestamp')
# Just verify that this raises no exceptions.
datetime.datetime.strptime(handler.messages[-1][:23],
'%Y-%m-%d %H:%M:%S,%f')
开发者ID:AlanWasTaken,项目名称:servo,代码行数:13,代码来源:test_logger.py
示例19: __init__
def __init__(self, directory, version, platform=None,
application='firefox', locale='en-US', extension=None,
authentication=None, retry_attempts=0, retry_delay=10.,
is_stub_installer=False, timeout=None, log_level='INFO',
base_url=BASE_URL):
# Private properties for caching
self._target = None
self._binary = None
self.directory = directory
self.locale = locale
self.platform = platform or self.detect_platform()
self.version = version
self.extension = extension or DEFAULT_FILE_EXTENSIONS[self.platform]
self.authentication = authentication
self.retry_attempts = retry_attempts
self.retry_delay = retry_delay
self.is_stub_installer = is_stub_installer
self.timeout_download = timeout
self.timeout_network = 60.
self.logger = mozlog.getLogger(' ')
self.logger.setLevel(getattr(mozlog, log_level.upper()))
# build the base URL
self.application = application
self.base_url = urljoin(base_url, self.application)
attempt = 0
while True:
attempt += 1
try:
self.get_build_info()
break
except (NotFoundError, requests.exceptions.RequestException), e:
if self.retry_attempts > 0:
# Log only if multiple attempts are requested
self.logger.warning("Build not found: '%s'" % e.message)
self.logger.info('Will retry in %s seconds...' %
(self.retry_delay))
time.sleep(self.retry_delay)
self.logger.info("Retrying... (attempt %s)" % attempt)
if attempt >= self.retry_attempts:
if hasattr(e, 'response') and \
e.response.status_code == 404:
message = "Specified build has not been found"
raise NotFoundError(message, e.response.url)
else:
raise
开发者ID:manzee,项目名称:mozdownload,代码行数:51,代码来源:scraper.py
示例20: __init__
def __init__(self, **kwargs):
# Set up the log file or use stdout if none specified
self.log = mozlog.getLogger('FIREBUG', kwargs.get('log'))
self.log.setLevel(mozlog.DEBUG if kwargs.get('debug') else mozlog.INFO)
# Initialization
self.binary = kwargs.get('binary')
self.profile = kwargs.get('profile')
self.serverpath = kwargs.get('serverpath')
self.testlist = kwargs.get('testlist')
self.couchURI = kwargs.get('couchURI')
self.databasename = kwargs.get('databasename')
self.section = kwargs.get('section')
self.platform = platform.system().lower()
# Read in fb-test-runner.config for local configuration
localConfig = ConfigParser()
localConfig.read(self.LOCAL_CONFIG)
if not self.serverpath:
self.serverpath = localConfig.get("runner_args", "server")
# Ensure serverpath has correct format
self.serverpath = self.serverpath.rstrip("/") + "/"
# Get the platform independent app directory and version
self.appdir, self.appVersion = self.get_app_info()
# Read in the Firebug team's config file
try:
self.download(self.serverpath + self.REMOTE_CONFIG, "test-bot.config")
except urllib2.URLError:
self.log.error("Could not download test-bot.config, check that '" + self.serverpath + self.REMOTE_CONFIG + "' is valid")
self.log.error(traceback.format_exc())
raise
self.config = ConfigParser()
self.config.read("test-bot.config")
# Make sure we have a testlist
if not self.testlist:
try:
self.testlist = self.config.get(self.section, "TEST_LIST")
except Exception:
self.log.error("No testlist specified in config file")
raise
if self.config.has_option(self.section, "DB_NAME"):
self.databasename = self.config.get(self.section, "DB_NAME")
if self.config.has_option(self.section, "DB_URL"):
self.couchURI = self.config.get(self.section, "DB_URL")
开发者ID:ahal,项目名称:Firebug-Test-Runner,代码行数:50,代码来源:fb_run.py
注:本文中的mozlog.getLogger函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论