2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-22 09:57:15 +01:00

The progress bar should always appear on stderr

This commit is contained in:
Thomas Nagy 2014-01-23 22:22:15 +01:00
parent 2943824c51
commit d413616400
3 changed files with 15 additions and 8 deletions

View File

@ -265,7 +265,7 @@ class BuildContext(Context.Context):
try:
self.compile()
finally:
if self.progress_bar == 1:
if self.progress_bar == 1 and sys.stderr.isatty():
c = len(self.returned_tasks) or 1
m = self.progress_line(c, c, Logs.colors.BLUE, Logs.colors.NORMAL)
Logs.info(m, extra={'stream': sys.stderr, 'c1': Logs.colors.cursor_off, 'c2' : Logs.colors.cursor_on})

View File

@ -132,10 +132,13 @@ class log_handler(logging.StreamHandler):
def emit(self, record):
# default implementation
try:
if record.levelno >= logging.WARNING:
record.stream = self.stream = sys.stderr
else:
record.stream = self.stream = sys.stdout
try:
self.stream = record.stream
except AttributeError:
if record.levelno >= logging.WARNING:
record.stream = self.stream = sys.stderr
else:
record.stream = self.stream = sys.stdout
self.emit_override(record)
self.flush()
except (KeyboardInterrupt, SystemExit):

View File

@ -252,10 +252,14 @@ class TaskBase(evil):
c1 = Logs.colors.cursor_off
c2 = Logs.colors.cursor_on
if bld.logger:
fun = bld.logger.info
logger = bld.logger
else:
fun = Logs.info
fun(self.display(), extra={'stream': sys.stderr, 'terminator':'', 'c1': c1, 'c2' : c2})
logger = Logs
if stderr:
logger.info(self.display(), extra={'stream': sys.stderr, 'terminator':'', 'c1': c1, 'c2' : c2})
else:
logger.info(self.display(), extra={'terminator':'', 'c1': c1, 'c2' : c2})
def display(self):
"""