mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1026181 - Make mach terminal formatter work outside mach context, r=wlach
This commit is contained in:
parent
c66b952b81
commit
93242027db
@ -62,7 +62,7 @@ def add_logging_group(parser):
|
||||
help=help_str)
|
||||
|
||||
|
||||
def setup_logging(suite, args, defaults):
|
||||
def setup_logging(suite, args, defaults=None):
|
||||
"""
|
||||
Configure a structuredlogger based on command line arguments.
|
||||
|
||||
@ -73,7 +73,10 @@ def setup_logging(suite, args, defaults):
|
||||
:param args: A dictionary of {argument_name:value} produced from
|
||||
parsing the command line arguments for the application
|
||||
:param defaults: A dictionary of {formatter name: output stream} to apply
|
||||
when there is no logging supplied on the command line.
|
||||
when there is no logging supplied on the command line. If
|
||||
this isn't supplied, reasonable defaults are chosen
|
||||
(coloured mach formatting if stdout is a terminal, or raw
|
||||
logs otherwise).
|
||||
|
||||
:rtype: StructuredLogger
|
||||
"""
|
||||
@ -83,6 +86,13 @@ def setup_logging(suite, args, defaults):
|
||||
found_stdout_logger = False
|
||||
if not hasattr(args, 'iteritems'):
|
||||
args = vars(args)
|
||||
|
||||
if defaults is None:
|
||||
if sys.__stdout__.isatty():
|
||||
defaults = {"mach_terminal": sys.stdout}
|
||||
else:
|
||||
defaults = {"raw": sys.stdout}
|
||||
|
||||
for name, values in args.iteritems():
|
||||
if name.startswith(prefix) and values is not None:
|
||||
for value in values:
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
import time
|
||||
|
||||
import blessings
|
||||
|
||||
import base
|
||||
|
||||
|
||||
@ -134,6 +136,8 @@ class MachTerminalFormatter(BaseMachFormatter):
|
||||
"""
|
||||
def __init__(self, start_time=None, write_interval=False, write_times=True,
|
||||
terminal=None):
|
||||
if terminal is None:
|
||||
terminal = blessings.Terminal()
|
||||
self.terminal = terminal
|
||||
BaseMachFormatter.__init__(self,
|
||||
start_time=start_time,
|
||||
|
@ -17,6 +17,7 @@ setup(name=PACKAGE_NAME,
|
||||
license='MPL 1.1/GPL 2.0/LGPL 2.1',
|
||||
packages=find_packages(),
|
||||
zip_safe=False,
|
||||
install_requires=["blessings>=1.3"],
|
||||
tests_require=['mozfile'],
|
||||
platforms =['Any'],
|
||||
classifiers=['Development Status :: 4 - Beta',
|
||||
|
Loading…
Reference in New Issue
Block a user