summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/bb/__init__.py31
-rw-r--r--bitbake/lib/bb/build.py2
-rw-r--r--bitbake/lib/bb/msg.py70
-rw-r--r--bitbake/lib/bb/ui/buildinfohelper.py11
-rw-r--r--bitbake/lib/bb/ui/knotty.py14
5 files changed, 54 insertions, 74 deletions
diff --git a/bitbake/lib/bb/__init__.py b/bitbake/lib/bb/__init__.py
index dc5e91e29a9..1453abe6bf8 100644
--- a/bitbake/lib/bb/__init__.py
+++ b/bitbake/lib/bb/__init__.py
@@ -21,8 +21,8 @@ class BBHandledException(Exception):
The big dilemma for generic bitbake code is what information to give the user
when an exception occurs. Any exception inheriting this base exception class
has already provided information to the user via some 'fired' message type such as
- an explicitly fired event using bb.fire, or a bb.error message. If bitbake
- encounters an exception derived from this class, no backtrace or other information
+ an explicitly fired event using bb.fire, or a bb.error message. If bitbake
+ encounters an exception derived from this class, no backtrace or other information
will be given to the user, its assumed the earlier event provided the relevant information.
"""
pass
@@ -52,21 +52,38 @@ class BBLogger(Logger):
return self.log(loglevel, msg, *args, **kwargs)
def plain(self, msg, *args, **kwargs):
- return self.log(logging.INFO + 1, msg, *args, **kwargs)
+ return self.log(logging.PLAIN, msg, *args, **kwargs)
def verbose(self, msg, *args, **kwargs):
- return self.log(logging.INFO - 1, msg, *args, **kwargs)
+ return self.log(logging.VERBOSE, msg, *args, **kwargs)
def verbnote(self, msg, *args, **kwargs):
- return self.log(logging.INFO + 2, msg, *args, **kwargs)
-
+ return self.log(logging.VERBNOTE, msg, *args, **kwargs)
+
+# Add bitbake's logging levels and names to the logging module. This isn't
+# considered the best practice, but bitbake has many legacy logging levels
+# to deal with
+logging.DEBUG3 = logging.DEBUG - 2
+logging.DEBUG2 = logging.DEBUG - 1
+logging.VERBOSE = logging.INFO - 1
+logging.NOTE = logging.INFO
+logging.PLAIN = logging.INFO + 1
+logging.VERBNOTE = logging.INFO + 2
+
+logging.addLevelName(logging.DEBUG3, 'DEBUG')
+logging.addLevelName(logging.DEBUG2, 'DEBUG')
+logging.addLevelName(logging.VERBOSE, 'NOTE')
+logging.addLevelName(logging.NOTE, 'NOTE')
+logging.addLevelName(logging.PLAIN, '')
+logging.addLevelName(logging.VERBNOTE, 'NOTE')
+logging.addLevelName(logging.CRITICAL, 'ERROR')
logging.raiseExceptions = False
logging.setLoggerClass(BBLogger)
logger = logging.getLogger("BitBake")
logger.addHandler(NullHandler())
-logger.setLevel(logging.DEBUG - 2)
+logger.setLevel(logging.DEBUG3)
mainlogger = logging.getLogger("BitBake.Main")
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py
index 23b6ee455ff..246231f2327 100644
--- a/bitbake/lib/bb/build.py
+++ b/bitbake/lib/bb/build.py
@@ -560,7 +560,7 @@ def _exec_task(fn, task, d, quieterr):
handler = logging.StreamHandler(logfile)
handler.setFormatter(logformatter)
# Always enable full debug output into task logfiles
- handler.setLevel(logging.DEBUG - 2)
+ handler.setLevel(logging.DEBUG3)
bblogger.addHandler(handler)
errchk = ErrorCheckHandler()
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
diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py
index 82c62e3324b..f5dab41bac5 100644
--- a/bitbake/lib/bb/ui/buildinfohelper.py
+++ b/bitbake/lib/bb/ui/buildinfohelper.py
@@ -39,7 +39,6 @@ from bldcontrol.models import BuildEnvironment, BuildRequest
from bldcontrol.models import BRLayer
from bldcontrol import bbcontroller
-from bb.msg import BBLogFormatter as formatter
from django.db import models
from pprint import pformat
import logging
@@ -1589,7 +1588,7 @@ class BuildInfoHelper(object):
def store_log_error(self, text):
mockevent = MockEvent()
- mockevent.levelno = formatter.ERROR
+ mockevent.levelno = logging.ERROR
mockevent.msg = text
mockevent.pathname = '-- None'
mockevent.lineno = LogMessage.ERROR
@@ -1606,7 +1605,7 @@ class BuildInfoHelper(object):
def store_log_event(self, event,cli_backlog=True):
self._ensure_build()
- if event.levelno < formatter.WARNING:
+ if event.levelno < logging.WARNING:
return
# early return for CLI builds
@@ -1629,11 +1628,11 @@ class BuildInfoHelper(object):
log_information = {}
log_information['build'] = self.internal_state['build']
- if event.levelno == formatter.CRITICAL:
+ if event.levelno == logging.CRITICAL:
log_information['level'] = LogMessage.CRITICAL
- elif event.levelno == formatter.ERROR:
+ elif event.levelno == logging.ERROR:
log_information['level'] = LogMessage.ERROR
- elif event.levelno == formatter.WARNING:
+ elif event.levelno == logging.WARNING:
log_information['level'] = LogMessage.WARNING
elif event.levelno == -2: # toaster self-logging
log_information['level'] = -2
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index 87e873d644a..33ee891256a 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -113,7 +113,7 @@ class InteractConsoleLogFilter(logging.Filter):
self.tf = tf
def filter(self, record):
- if record.levelno == bb.msg.BBLogFormatter.NOTE and (record.msg.startswith("Running") or record.msg.startswith("recipe ")):
+ if record.levelno == logging.NOTE and (record.msg.startswith("Running") or record.msg.startswith("recipe ")):
return False
self.tf.clearFooter()
return True
@@ -392,9 +392,9 @@ def main(server, eventHandler, params, tf = TerminalFilter):
if params.options.quiet == 0:
console_loglevel = loglevel
elif params.options.quiet > 2:
- console_loglevel = bb.msg.BBLogFormatter.ERROR
+ console_loglevel = logging.ERROR
else:
- console_loglevel = bb.msg.BBLogFormatter.WARNING
+ console_loglevel = logging.WARNING
logconfig = {
"version": 1,
@@ -626,21 +626,21 @@ def main(server, eventHandler, params, tf = TerminalFilter):
if isinstance(event, logging.LogRecord):
lastprint = time.time()
printinterval = 5000
- if event.levelno >= bb.msg.BBLogFormatter.ERROR:
+ if event.levelno >= logging.ERROR:
errors = errors + 1
return_value = 1
- elif event.levelno == bb.msg.BBLogFormatter.WARNING:
+ elif event.levelno == logging.WARNING:
warnings = warnings + 1
if event.taskpid != 0:
# For "normal" logging conditions, don't show note logs from tasks
# but do show them if the user has changed the default log level to
# include verbose/debug messages
- if event.levelno <= bb.msg.BBLogFormatter.NOTE and (event.levelno < llevel or (event.levelno == bb.msg.BBLogFormatter.NOTE and llevel != bb.msg.BBLogFormatter.VERBOSE)):
+ if event.levelno <= logging.NOTE and (event.levelno < llevel or (event.levelno == logging.NOTE and llevel != logging.VERBOSE)):
continue
# Prefix task messages with recipe/task
- if event.taskpid in helper.pidmap and event.levelno != bb.msg.BBLogFormatter.PLAIN:
+ if event.taskpid in helper.pidmap and event.levelno != logging.PLAIN:
taskinfo = helper.running_tasks[helper.pidmap[event.taskpid]]
event.msg = taskinfo['title'] + ': ' + event.msg
if hasattr(event, 'fn'):