mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1097901 - Improve structured log example + docs;r=jgraham DONTBUILD
This commit is contained in:
parent
6f02f11051
commit
c6e1b09506
@ -3,7 +3,7 @@ import sys
|
||||
import traceback
|
||||
import types
|
||||
|
||||
from mozlog.structured import structuredlog, commandline
|
||||
from mozlog.structured import commandline, get_default_logger
|
||||
|
||||
class TestAssertion(Exception):
|
||||
pass
|
||||
@ -35,8 +35,8 @@ def test_expected_fail():
|
||||
assert_equals(2 + 2, 5)
|
||||
|
||||
class TestRunner(object):
|
||||
def __init__(self, logger):
|
||||
self.logger = logger
|
||||
def __init__(self):
|
||||
self.logger = get_default_logger(component='TestRunner')
|
||||
|
||||
def gather_tests(self):
|
||||
for item in globals().itervalues():
|
||||
@ -81,7 +81,7 @@ def main():
|
||||
|
||||
logger = commandline.setup_logging("structured-example", args, {"raw": sys.stdout})
|
||||
|
||||
runner = TestRunner(logger)
|
||||
runner = TestRunner()
|
||||
try:
|
||||
runner.run()
|
||||
except:
|
||||
|
@ -124,7 +124,7 @@ def setup_logging(suite, args, defaults=None):
|
||||
Configure a structuredlogger based on command line arguments.
|
||||
|
||||
The created structuredlogger will also be set as the default logger, and
|
||||
can be retrieved with :py:func:`get_default_logger`.
|
||||
can be retrieved with :py:func:`~mozlog.structured.structuredlog.get_default_logger`.
|
||||
|
||||
:param suite: The name of the testsuite being run
|
||||
:param args: A dictionary of {argument_name:value} produced from
|
||||
|
@ -79,6 +79,10 @@ def set_default_logger(default_logger):
|
||||
|
||||
It can then be retrieved with :py:func:`get_default_logger`
|
||||
|
||||
Note that :py:func:`~mozlog.structured.commandline.setup_logging` will
|
||||
set a default logger for you, so there should be no need to call this
|
||||
function if you're using setting up logging that way (recommended).
|
||||
|
||||
:param default_logger: The logger to set to default.
|
||||
"""
|
||||
global _default_logger_name
|
||||
|
Loading…
Reference in New Issue
Block a user