minor bug fix to make --disable-coloring work on log messages too

This commit is contained in:
Bernardo Damele 2013-02-06 21:04:54 +00:00
parent 2fa2f30d21
commit 5c8335876f
2 changed files with 17 additions and 4 deletions

View File

@ -729,6 +729,9 @@ def boldifyMessage(message):
return retVal
def setColor(message, bold=False):
if conf.disableColoring:
return message
retVal = message
level = extractRegexResult(r"\[(?P<result>[A-Z ]+)\]", message) or kb.get("stickyLevel")

View File

@ -20,10 +20,20 @@ LOGGER_HANDLER = None
try:
from thirdparty.ansistrm.ansistrm import ColorizingStreamHandler
LOGGER_HANDLER = ColorizingStreamHandler(sys.stdout)
LOGGER_HANDLER.level_map[logging.getLevelName("PAYLOAD")] = (None, "cyan", False)
LOGGER_HANDLER.level_map[logging.getLevelName("TRAFFIC OUT")] = (None, "magenta", False)
LOGGER_HANDLER.level_map[logging.getLevelName("TRAFFIC IN")] = ("magenta", None, False)
disableColoring = False
for argument in sys.argv:
if "disable-col" in argument:
disableColoring = True
break
if disableColoring:
LOGGER_HANDLER = logging.StreamHandler(sys.stdout)
else:
LOGGER_HANDLER = ColorizingStreamHandler(sys.stdout)
LOGGER_HANDLER.level_map[logging.getLevelName("PAYLOAD")] = (None, "cyan", False)
LOGGER_HANDLER.level_map[logging.getLevelName("TRAFFIC OUT")] = (None, "magenta", False)
LOGGER_HANDLER.level_map[logging.getLevelName("TRAFFIC IN")] = ("magenta", None, False)
except ImportError:
LOGGER_HANDLER = logging.StreamHandler(sys.stdout)