Fix for an Issue #140

This commit is contained in:
Miroslav Stampar 2012-08-07 10:57:29 +02:00
parent fec8a5cc9d
commit 31ceb0cb6c
2 changed files with 4 additions and 2 deletions

View File

@ -701,7 +701,7 @@ def setColor(message, bold=False):
retVal = message
level = extractRegexResult(r"\[(?P<result>[A-Z ]+)\]", message) or kb.get("stickyLevel")
if message and hasattr(LOGGER_HANDLER, "level_map"): # colorizing handler
if message and getattr(LOGGER_HANDLER, "is_tty", False): # colorizing handler
if bold:
retVal = colored(message, color=None, on_color=None, attrs=("bold",))
elif level:

View File

@ -51,6 +51,8 @@ class ColorizingStreamHandler(logging.StreamHandler):
stream = self.stream
if not self.is_tty:
if message and message[0] == "\r":
message = message[1:]
stream.write(message)
else:
self.output_colorized(message)
@ -122,7 +124,7 @@ class ColorizingStreamHandler(logging.StreamHandler):
ctypes.windll.kernel32.SetConsoleTextAttribute(h, color)
def colorize(self, message, record):
if record.levelno in self.level_map:
if record.levelno in self.level_map and self.is_tty:
bg, fg, bold = self.level_map[record.levelno]
params = []