diff options
author | Chris Larson <chris_larson@mentor.com> | 2010-06-10 10:35:31 -0700 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2011-01-04 14:46:33 +0000 |
commit | ecc68fa4fbb579e97ea45156e79a293b073697a0 (patch) | |
tree | 6d08682e43476e37ccf48ee14c8d81e208d1c897 /bitbake/lib/bb/build.py | |
parent | d3a45c7d41a88d79389fc40eb68816e4939fb6f9 (diff) | |
download | poky-ecc68fa4fbb579e97ea45156e79a293b073697a0.tar.gz |
Switch bitbake internals to use logging directly rather than bb.msg
We use a custom Logger subclass for our loggers
This logger provides:
- 'debug' method which accepts a debug level
- 'plain' method which bypasses log formatting
- 'verbose' method which is more detail than info, but less than debug
(Bitbake rev: 3b2c1fe5ca56daebb24073a9dd45723d3efd2a8d)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb/build.py')
-rw-r--r-- | bitbake/lib/bb/build.py | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py index 18a75edca3..9589313238 100644 --- a/bitbake/lib/bb/build.py +++ b/bitbake/lib/bb/build.py | |||
@@ -26,9 +26,14 @@ | |||
26 | #Based on functions from the base bb module, Copyright 2003 Holger Schurig | 26 | #Based on functions from the base bb module, Copyright 2003 Holger Schurig |
27 | 27 | ||
28 | from bb import data, event, mkdirhier, utils | 28 | from bb import data, event, mkdirhier, utils |
29 | import bb, os, sys | 29 | import os |
30 | import sys | ||
31 | import logging | ||
32 | import bb | ||
30 | import bb.utils | 33 | import bb.utils |
31 | 34 | ||
35 | logger = logging.getLogger("BitBake.Build") | ||
36 | |||
32 | # When we execute a python function we'd like certain things | 37 | # When we execute a python function we'd like certain things |
33 | # in all namespaces, hence we add them to __builtins__ | 38 | # in all namespaces, hence we add them to __builtins__ |
34 | # If we do not do this and use the exec globals, they will | 39 | # If we do not do this and use the exec globals, they will |
@@ -193,7 +198,8 @@ def exec_func_shell(func, d, runfile, logfile, flags): | |||
193 | 198 | ||
194 | f = open(runfile, "w") | 199 | f = open(runfile, "w") |
195 | f.write("#!/bin/sh -e\n") | 200 | f.write("#!/bin/sh -e\n") |
196 | if bb.msg.debug_level['default'] > 0: f.write("set -x\n") | 201 | if logger.getEffectiveLevel() <= logging.DEBUG: |
202 | f.write("set -x\n") | ||
197 | data.emit_func(func, f, d) | 203 | data.emit_func(func, f, d) |
198 | 204 | ||
199 | f.write("cd %s\n" % os.getcwd()) | 205 | f.write("cd %s\n" % os.getcwd()) |
@@ -226,7 +232,7 @@ def exec_task(fn, task, d): | |||
226 | # Check whther this is a valid task | 232 | # Check whther this is a valid task |
227 | if not data.getVarFlag(task, 'task', d): | 233 | if not data.getVarFlag(task, 'task', d): |
228 | event.fire(TaskInvalid(task, d), d) | 234 | event.fire(TaskInvalid(task, d), d) |
229 | bb.msg.error(bb.msg.domain.Build, "No such task: %s" % task) | 235 | logger.error("No such task: %s" % task) |
230 | return 1 | 236 | return 1 |
231 | 237 | ||
232 | quieterr = False | 238 | quieterr = False |
@@ -234,7 +240,7 @@ def exec_task(fn, task, d): | |||
234 | quieterr = True | 240 | quieterr = True |
235 | 241 | ||
236 | try: | 242 | try: |
237 | bb.msg.debug(1, bb.msg.domain.Build, "Executing task %s" % task) | 243 | logger.debug(1, "Executing task %s", task) |
238 | old_overrides = data.getVar('OVERRIDES', d, 0) | 244 | old_overrides = data.getVar('OVERRIDES', d, 0) |
239 | localdata = data.createCopy(d) | 245 | localdata = data.createCopy(d) |
240 | data.setVar('OVERRIDES', 'task-%s:%s' % (task[3:], old_overrides), localdata) | 246 | data.setVar('OVERRIDES', 'task-%s:%s' % (task[3:], old_overrides), localdata) |
@@ -269,8 +275,8 @@ def exec_task(fn, task, d): | |||
269 | si = file('/dev/null', 'r') | 275 | si = file('/dev/null', 'r') |
270 | try: | 276 | try: |
271 | so = file(logfile, 'w') | 277 | so = file(logfile, 'w') |
272 | except OSError as e: | 278 | except OSError: |
273 | bb.msg.error(bb.msg.domain.Build, "opening log file: %s" % e) | 279 | logger.exception("Opening log file '%s'", logfile) |
274 | pass | 280 | pass |
275 | se = so | 281 | se = so |
276 | 282 | ||
@@ -312,7 +318,7 @@ def exec_task(fn, task, d): | |||
312 | logfile = None | 318 | logfile = None |
313 | msg = message | 319 | msg = message |
314 | if not quieterr: | 320 | if not quieterr: |
315 | bb.msg.error(bb.msg.domain.Build, "Task failed: %s" % message ) | 321 | logger.error("Task failed: %s" % message ) |
316 | failedevent = TaskFailed(msg, logfile, task, d) | 322 | failedevent = TaskFailed(msg, logfile, task, d) |
317 | event.fire(failedevent, d) | 323 | event.fire(failedevent, d) |
318 | return 1 | 324 | return 1 |
@@ -320,8 +326,8 @@ def exec_task(fn, task, d): | |||
320 | except Exception: | 326 | except Exception: |
321 | from traceback import format_exc | 327 | from traceback import format_exc |
322 | if not quieterr: | 328 | if not quieterr: |
323 | bb.msg.error(bb.msg.domain.Build, "Build of %s failed" % (task)) | 329 | logger.error("Build of %s failed" % (task)) |
324 | bb.msg.error(bb.msg.domain.Build, format_exc()) | 330 | logger.error(format_exc()) |
325 | failedevent = TaskFailed("Task Failed", None, task, d) | 331 | failedevent = TaskFailed("Task Failed", None, task, d) |
326 | event.fire(failedevent, d) | 332 | event.fire(failedevent, d) |
327 | return 1 | 333 | return 1 |
@@ -342,7 +348,7 @@ def exec_task(fn, task, d): | |||
342 | se.close() | 348 | se.close() |
343 | 349 | ||
344 | if logfile and os.path.exists(logfile) and os.path.getsize(logfile) == 0: | 350 | if logfile and os.path.exists(logfile) and os.path.getsize(logfile) == 0: |
345 | bb.msg.debug(2, bb.msg.domain.Build, "Zero size logfile %s, removing" % logfile) | 351 | logger.debug(2, "Zero size logfile %s, removing", logfile) |
346 | os.remove(logfile) | 352 | os.remove(logfile) |
347 | try: | 353 | try: |
348 | os.remove(loglink) | 354 | os.remove(loglink) |