From 8893507fbbdf6b2db9e5470da8a9d25c966b9f2d Mon Sep 17 00:00:00 2001 From: brentholtsclaw Date: Mon, 31 Jan 2022 12:56:53 -0800 Subject: [PATCH] Create new logging levels Signed-off-by: brentholtsclaw --- chipsec/logger.py | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/chipsec/logger.py b/chipsec/logger.py index 2727a7c1..4c58e467 100644 --- a/chipsec/logger.py +++ b/chipsec/logger.py @@ -67,12 +67,15 @@ class ColorLogger(pyLogging.Formatter): WHITE = WConio.WHITE LEVEL_ID = { - pyLogging.DEBUG: GREEN, - pyLogging.INFO: WHITE, + pyLogging.ERROR: MAGENTA, + 39: BLUE, pyLogging.WARNING: YELLOW, - pyLogging.CRITICAL: BLUE, - pyLogging.ERROR: RED - } + 29: RED, + 28: GREEN, + pyLogging.INFO: WHITE, + 19: WHITE, + 18: WHITE, + pyLogging.DEBUG: WHITE} def log_color(self, message, record): """ Testing """ @@ -110,11 +113,15 @@ class ColorLogger(pyLogging.Formatter): reset = '\x1b[0m' LEVEL_ID = { - pyLogging.DEBUG: GREEN, - pyLogging.INFO: WHITE, + pyLogging.ERROR: PURPLE, + 39: BLUE, pyLogging.WARNING: YELLOW, - pyLogging.CRITICAL: BLUE, - pyLogging.ERROR: RED + 29: RED, + 28: GREEN, + pyLogging.INFO: WHITE, + 19: LIGHT_GRAY, + 18: LIGHT_GRAY, + pyLogging.DEBUG: LIGHT_GRAY } def log_color(self, message, record): @@ -138,13 +145,14 @@ class Logger: """The Constructor.""" self.mytime = localtime() self.logfile = None - self.debug = pyLogging.DEBUG - self.info = pyLogging.INFO self.rootLogger = pyLogging.getLogger(__name__) - self.rootLogger.setLevel(self.debug) + self.rootLogger.setLevel(pyLogging.INFO) self.ALWAYS_FLUSH = False - pyLogging.addLevelName(15, "verbose") - self.verbose = 15 + pyLogging.addLevelName(19, "verbose") + pyLogging.addLevelName(18, "hal") + pyLogging.addLevelName(29, "bad") + pyLogging.addLevelName(28, "good") + pyLogging.addLevelName(39, "header") self.logstream = pyLogging.StreamHandler(sys.stdout) # Respect https://no-color.org/ convention, and disable colorization # when the output is not a terminal (eg. redirection to a file)