bitbake/__init__.py: Add taskpid to all LogRecords (subclassed to be BBLogRecords)

This allows us to identify which task messages are from.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2011-01-07 23:52:19 +00:00
parent a13352cfaf
commit f8e7215f6c
1 changed files with 8 additions and 0 deletions

View File

@ -35,6 +35,11 @@ class NullHandler(logging.Handler):
def emit(self, record):
pass
class BBLogRecord(logging.LogRecord):
def __init__(self, name, level, fn, lno, msg, args, exc_info, func, extra):
self.taskpid = bb.event.worker_pid
logging.LogRecord.__init__(self, name, level, fn, lno, msg, args, exc_info, func)
Logger = logging.getLoggerClass()
class BBLogger(Logger):
def __init__(self, name):
@ -42,6 +47,9 @@ class BBLogger(Logger):
self.debug = self.bbdebug
Logger.__init__(self, name)
def makeRecord(self, name, lvl, fn, lno, msg, args, exc_info, func=None, extra=None):
return BBLogRecord(name, lvl, fn, lno, msg, args, exc_info, func, extra)
def bbdebug(self, level, msg, *args, **kwargs):
return self.log(logging.DEBUG - level - 1, msg, *args, **kwargs)