diff options
author | Chris Larson <chris_larson@mentor.com> | 2011-01-10 09:20:50 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-01-10 22:09:11 +0000 |
commit | 810e139fd3626acdf23372426526bceb7ccb1abf (patch) | |
tree | d899760cf06b5acdc68cce509e08e09d8c0874d7 /bitbake | |
parent | 48e567bb477ad468dcfbab0d97019a6a85520ede (diff) | |
download | poky-810e139fd3626acdf23372426526bceb7ccb1abf.tar.gz |
Inject taskpid into log records via our log handler
It turns out that while log filters added with addFilter are only associated
with that logger, and not its children, handlers are inherited, and handlers
can be filters. So, let's add filtering to our existing LogHandler class
which dispatches our log records as bitbake events.
(Bitbake rev: 0153ace246e7c88366f45c8f035a2b4505a1c115)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/__init__.py | 8 | ||||
-rw-r--r-- | bitbake/lib/bb/event.py | 4 |
2 files changed, 4 insertions, 8 deletions
diff --git a/bitbake/lib/bb/__init__.py b/bitbake/lib/bb/__init__.py index e1ddbd53ff..de8100c0cb 100644 --- a/bitbake/lib/bb/__init__.py +++ b/bitbake/lib/bb/__init__.py | |||
@@ -35,11 +35,6 @@ class NullHandler(logging.Handler): | |||
35 | def emit(self, record): | 35 | def emit(self, record): |
36 | pass | 36 | pass |
37 | 37 | ||
38 | class BBLogRecord(logging.LogRecord): | ||
39 | def __init__(self, name, level, fn, lno, msg, args, exc_info, func, extra): | ||
40 | self.taskpid = bb.event.worker_pid | ||
41 | logging.LogRecord.__init__(self, name, level, fn, lno, msg, args, exc_info, func) | ||
42 | |||
43 | Logger = logging.getLoggerClass() | 38 | Logger = logging.getLoggerClass() |
44 | class BBLogger(Logger): | 39 | class BBLogger(Logger): |
45 | def __init__(self, name): | 40 | def __init__(self, name): |
@@ -47,9 +42,6 @@ class BBLogger(Logger): | |||
47 | self.debug = self.bbdebug | 42 | self.debug = self.bbdebug |
48 | Logger.__init__(self, name) | 43 | Logger.__init__(self, name) |
49 | 44 | ||
50 | def makeRecord(self, name, lvl, fn, lno, msg, args, exc_info, func=None, extra=None): | ||
51 | return BBLogRecord(name, lvl, fn, lno, msg, args, exc_info, func, extra) | ||
52 | |||
53 | def bbdebug(self, level, msg, *args, **kwargs): | 45 | def bbdebug(self, level, msg, *args, **kwargs): |
54 | return self.log(logging.DEBUG - level - 1, msg, *args, **kwargs) | 46 | return self.log(logging.DEBUG - level - 1, msg, *args, **kwargs) |
55 | 47 | ||
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py index 450d913633..bd2042a99c 100644 --- a/bitbake/lib/bb/event.py +++ b/bitbake/lib/bb/event.py | |||
@@ -384,3 +384,7 @@ class LogHandler(logging.Handler): | |||
384 | fire(record, None) | 384 | fire(record, None) |
385 | if bb.event.useStdout: | 385 | if bb.event.useStdout: |
386 | print(self.format(record)) | 386 | print(self.format(record)) |
387 | |||
388 | def filter(self, record): | ||
389 | record.taskpid = worker_pid | ||
390 | return True | ||