]> code.ossystems Code Review - openembedded-core.git/commitdiff
Fix logging level names for post-server-ui-split
authorChris Larson <chris_larson@mentor.com>
Fri, 17 Dec 2010 18:49:31 +0000 (11:49 -0700)
committerRichard Purdie <rpurdie@linux.intel.com>
Tue, 4 Jan 2011 14:46:52 +0000 (14:46 +0000)
(Bitbake rev: dc5a5c39291ec223cd761dce59d29eee7316cb70)

Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
bitbake/lib/bb/msg.py
bitbake/lib/bb/ui/knotty.py

index 36d7060b1c0b78b359043ca0a74f00b51fb7f453..badc371ce12db53321abea9886984fc15eb7e725 100644 (file)
@@ -33,7 +33,28 @@ import bb.event
 class BBLogFormatter(logging.Formatter):
     """Formatter which ensures that our 'plain' messages (logging.INFO + 1) are used as is"""
 
+    VERBOSE = 19
+    PLAIN = 21
+    levelnames = {
+        PLAIN  : '',
+        VERBOSE: 'NOTE',
+
+        logging.DEBUG   : 'DEBUG',
+        logging.INFO    : 'NOTE',
+        logging.WARNING : 'WARNING',
+        logging.ERROR   : 'ERROR',
+        logging.CRITICAL: 'ERROR',
+    }
+
+    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 == logging.INFO + 1:
             return record.getMessage()
         else:
index b9ad34f16a02314c8f2828be2c3951d04ff3b4ad..cedbe423061cf1f31fe39014637e6fc860c86856 100644 (file)
@@ -74,16 +74,6 @@ def main(server, eventHandler):
 
     helper = uihelper.BBUIHelper()
 
-    # Set up logging to stdout in our usual format
-    logging.addLevelName(logging.INFO, "NOTE")
-    logging.addLevelName(logging.CRITICAL, "FATAL")
-
-    for level in xrange(logging.INFO - 1, logging.DEBUG + 1, -1):
-        logging.addLevelName(level, logging.getLevelName(logging.INFO))
-
-    for level in xrange(logging.DEBUG - 1, 0, -1):
-        logging.addLevelName(level, logging.getLevelName(logging.DEBUG))
-
     console = logging.StreamHandler(sys.stdout)
     format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")
     console.setFormatter(format)