diff --git a/lib/core/common.py b/lib/core/common.py index 1ae589399..c4d93c5cd 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -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[A-Z ]+)\]", message) or kb.get("stickyLevel") diff --git a/lib/core/log.py b/lib/core/log.py index efd0bd465..e860a30df 100644 --- a/lib/core/log.py +++ b/lib/core/log.py @@ -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)