]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.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)
committerChris Larson <chris_larson@mentor.com>
Fri, 17 Dec 2010 18:52:24 +0000 (11:52 -0700)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
lib/bb/msg.py
lib/bb/ui/knotty.py

index 0c1fa3bfc452a465d1a303c7af324848193b3c64..13ee569e9a47886ada23719c32190e62ce118a74 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 0b47136cb981a38356662c357286e4e5d76f2220..29c71aef2991c9dd25d5860de200a96fa3f0c5ce 100644 (file)
@@ -72,16 +72,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, "ERROR")
-
-    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)