mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 847175 - mach mode to not prefix lines with times; r=ted
DONTBUILD (NPOTB)
This commit is contained in:
parent
832bbc8b9d
commit
c0d4e11009
@ -68,13 +68,14 @@ class StructuredHumanFormatter(logging.Formatter):
|
||||
self.last_time = None
|
||||
|
||||
def format(self, record):
|
||||
f = record.msg.format(**record.params)
|
||||
|
||||
if not self.write_times:
|
||||
return record.msg.format(**record.params)
|
||||
return f
|
||||
|
||||
elapsed = self._time(record)
|
||||
|
||||
return '%s %s' % (format_seconds(elapsed),
|
||||
record.msg.format(**record.params))
|
||||
return '%s %s' % (format_seconds(elapsed), f)
|
||||
|
||||
def _time(self, record):
|
||||
t = record.created - self.start_time
|
||||
@ -94,9 +95,13 @@ class StructuredTerminalFormatter(StructuredHumanFormatter):
|
||||
self.terminal = terminal
|
||||
|
||||
def format(self, record):
|
||||
t = self.terminal.blue(format_seconds(self._time(record)))
|
||||
f = record.msg.format(**record.params)
|
||||
|
||||
if not self.write_times:
|
||||
return f
|
||||
|
||||
t = self.terminal.blue(format_seconds(self._time(record)))
|
||||
|
||||
return '%s %s' % (t, self._colorize(f))
|
||||
|
||||
def _colorize(self, s):
|
||||
@ -177,15 +182,15 @@ class LoggingManager(object):
|
||||
self.json_handlers.append(handler)
|
||||
|
||||
def add_terminal_logging(self, fh=sys.stdout, level=logging.INFO,
|
||||
write_interval=False):
|
||||
write_interval=False, write_times=True):
|
||||
"""Enable logging to the terminal."""
|
||||
|
||||
formatter = StructuredHumanFormatter(self.start_time,
|
||||
write_interval=write_interval)
|
||||
write_interval=write_interval, write_times=write_times)
|
||||
|
||||
if self.terminal:
|
||||
formatter = StructuredTerminalFormatter(self.start_time,
|
||||
write_interval=write_interval)
|
||||
write_interval=write_interval, write_times=write_times)
|
||||
formatter.set_terminal(self.terminal)
|
||||
|
||||
handler = logging.StreamHandler(stream=fh)
|
||||
|
@ -330,10 +330,14 @@ To see more help for a specific command, run:
|
||||
|
||||
self.log_manager.register_structured_logger(logging.getLogger('mach'))
|
||||
|
||||
write_times = True
|
||||
if args.log_no_times or 'MACH_NO_WRITE_TIMES' in os.environ:
|
||||
write_times = False
|
||||
|
||||
# Always enable terminal logging. The log manager figures out if we are
|
||||
# actually in a TTY or are a pipe and does the right thing.
|
||||
self.log_manager.add_terminal_logging(level=log_level,
|
||||
write_interval=args.log_interval)
|
||||
write_interval=args.log_interval, write_times=write_times)
|
||||
|
||||
self.load_settings(args)
|
||||
|
||||
@ -511,6 +515,10 @@ To see more help for a specific command, run:
|
||||
help='Prefix log line with interval from last message rather '
|
||||
'than relative time. Note that this is NOT execution time '
|
||||
'if there are parallel operations.')
|
||||
global_group.add_argument('--log-no-times', dest='log_no_times',
|
||||
action='store_true', default=False,
|
||||
help='Do not prefix log lines with times. By default, mach will '
|
||||
'prefix each output line with the time since command start.')
|
||||
|
||||
# We need to be last because CommandAction swallows all remaining
|
||||
# arguments and argparse parses arguments in the order they were added.
|
||||
@ -518,4 +526,3 @@ To see more help for a specific command, run:
|
||||
registrar=Registrar, context=context)
|
||||
|
||||
return parser
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user