diff options
Diffstat (limited to 'bitbake/lib/bb/msg.py')
-rw-r--r-- | bitbake/lib/bb/msg.py | 70 |
1 files changed, 17 insertions, 53 deletions
diff --git a/bitbake/lib/bb/msg.py b/bitbake/lib/bb/msg.py index c0b344e3233..29f0a3999e7 100644 --- a/bitbake/lib/bb/msg.py +++ b/bitbake/lib/bb/msg.py @@ -21,60 +21,29 @@ import bb.event class BBLogFormatter(logging.Formatter): """Formatter which ensures that our 'plain' messages (logging.INFO + 1) are used as is""" - DEBUG3 = logging.DEBUG - 2 - DEBUG2 = logging.DEBUG - 1 - DEBUG = logging.DEBUG - VERBOSE = logging.INFO - 1 - NOTE = logging.INFO - PLAIN = logging.INFO + 1 - VERBNOTE = logging.INFO + 2 - ERROR = logging.ERROR - WARNING = logging.WARNING - CRITICAL = logging.CRITICAL - - levelnames = { - DEBUG3 : 'DEBUG', - DEBUG2 : 'DEBUG', - DEBUG : 'DEBUG', - VERBOSE: 'NOTE', - NOTE : 'NOTE', - PLAIN : '', - VERBNOTE: 'NOTE', - WARNING : 'WARNING', - ERROR : 'ERROR', - CRITICAL: 'ERROR', - } - color_enabled = False BASECOLOR, BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = list(range(29,38)) COLORS = { - DEBUG3 : CYAN, - DEBUG2 : CYAN, - DEBUG : CYAN, - VERBOSE : BASECOLOR, - NOTE : BASECOLOR, - PLAIN : BASECOLOR, - VERBNOTE: BASECOLOR, - WARNING : YELLOW, - ERROR : RED, - CRITICAL: RED, + logging.DEBUG3 : CYAN, + logging.DEBUG2 : CYAN, + logging.DEBUG : CYAN, + logging.VERBOSE : BASECOLOR, + logging.NOTE : BASECOLOR, + logging.PLAIN : BASECOLOR, + logging.VERBNOTE: BASECOLOR, + logging.WARNING : YELLOW, + logging.ERROR : RED, + logging.CRITICAL: RED, } BLD = '\033[1;%dm' STD = '\033[%dm' RST = '\033[0m' - def getLevelName(self, levelno): - try: - return self.levelnames[levelno] - except KeyError: - self.levelnames[levelno] = value = 'Level %d' % levelno - return value - def format(self, record): - record.levelname = self.getLevelName(record.levelno) - if record.levelno == self.PLAIN: + record.levelname = logging.getLevelName(record.levelno) + if record.levelno == logging.PLAIN: msg = record.getMessage() else: if self.color_enabled: @@ -145,7 +114,7 @@ class LogFilterLTLevel(logging.Filter): # Message control functions # -loggerDefaultLogLevel = BBLogFormatter.NOTE +loggerDefaultLogLevel = logging.NOTE loggerDefaultVerbose = False loggerVerboseLogs = False loggerDefaultDomains = {} @@ -159,11 +128,11 @@ def init_msgconfig(verbose, debug, debug_domains=None): bb.msg.loggerVerboseLogs = True if debug: - bb.msg.loggerDefaultLogLevel = BBLogFormatter.DEBUG - debug + 1 + bb.msg.loggerDefaultLogLevel = logging.DEBUG - debug + 1 elif verbose: - bb.msg.loggerDefaultLogLevel = BBLogFormatter.VERBOSE + bb.msg.loggerDefaultLogLevel = logging.VERBOSE else: - bb.msg.loggerDefaultLogLevel = BBLogFormatter.NOTE + bb.msg.loggerDefaultLogLevel = logging.NOTE bb.msg.loggerDefaultDomains = {} if debug_domains: @@ -188,12 +157,7 @@ def stringToLevel(level): except ValueError: pass - try: - return getattr(logging, level) - except AttributeError: - pass - - return getattr(BBLogFormatter, level) + return getattr(logging, level) # # Message handling functions |