mirror of https://gitlab.com/ita1024/waf.git
convoluted solution for Issue 1101
This commit is contained in:
parent
49f773b43c
commit
7033fb4767
|
@ -8,15 +8,44 @@ logging, colors, terminal width and pretty-print
|
||||||
|
|
||||||
import os, re, traceback, sys
|
import os, re, traceback, sys
|
||||||
|
|
||||||
_nocolor = os.environ.get('NOCOLOR', 'no') not in ('no', '0', 'false')
|
|
||||||
try:
|
try:
|
||||||
if not _nocolor:
|
import threading
|
||||||
import waflib.ansiterm
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# optional module for colors on win32, just ignore if it cannot be imported
|
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
wlock = threading.Lock()
|
||||||
|
|
||||||
import logging # do it after
|
class sync_stream(object):
|
||||||
|
def __init__(self, stream):
|
||||||
|
self.stream = stream
|
||||||
|
|
||||||
|
def write(self, txt):
|
||||||
|
try:
|
||||||
|
wlock.acquire()
|
||||||
|
self.stream.write(txt)
|
||||||
|
self.stream.flush()
|
||||||
|
finally:
|
||||||
|
wlock.release()
|
||||||
|
|
||||||
|
def flush(self):
|
||||||
|
self.stream.flush()
|
||||||
|
|
||||||
|
def isatty(self):
|
||||||
|
return self.stream.isatty()
|
||||||
|
|
||||||
|
_nocolor = os.environ.get('NOCOLOR', 'no') not in ('no', '0', 'false')
|
||||||
|
try:
|
||||||
|
if not _nocolor:
|
||||||
|
import waflib.ansiterm
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if not os.environ.get('NOSYNC', False):
|
||||||
|
if id(sys.stdout) == id(sys.__stdout__):
|
||||||
|
sys.stdout = sync_stream(sys.stdout)
|
||||||
|
sys.stderr = sync_stream(sys.stderr)
|
||||||
|
|
||||||
|
import logging # import other modules only after
|
||||||
|
|
||||||
LOG_FORMAT = "%(asctime)s %(c1)s%(zone)s%(c2)s %(message)s"
|
LOG_FORMAT = "%(asctime)s %(c1)s%(zone)s%(c2)s %(message)s"
|
||||||
HOUR_FORMAT = "%H:%M:%S"
|
HOUR_FORMAT = "%H:%M:%S"
|
||||||
|
|
Loading…
Reference in New Issue