aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bb/build.py
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-06-10 10:35:31 -0700
committerChris Larson <chris_larson@mentor.com>2010-09-03 18:51:54 -0700
commit3b2c1fe5ca56daebb24073a9dd45723d3efd2a8d (patch)
tree1f77ebed5e5f48fd786286a51dd697113cb7ea28 /lib/bb/build.py
parentc23c015cf8af1868faf293b19b80a5faf7e736a5 (diff)
downloadbitbake-3b2c1fe5ca56daebb24073a9dd45723d3efd2a8d.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 Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'lib/bb/build.py')
-rw-r--r--lib/bb/build.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/bb/build.py b/lib/bb/build.py
index 88ba1d541..c04a31880 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -26,9 +26,14 @@
#Based on functions from the base bb module, Copyright 2003 Holger Schurig
from bb import data, event, mkdirhier, utils
-import bb, os, sys
+import os
+import sys
+import logging
+import bb
import bb.utils
+logger = logging.getLogger("BitBake.Build")
+
# When we execute a python function we'd like certain things
# in all namespaces, hence we add them to __builtins__
# If we do not do this and use the exec globals, they will
@@ -137,12 +142,12 @@ def exec_func(func, d, dirs = None):
# Handle logfiles
si = file('/dev/null', 'r')
try:
- if bb.msg.debug_level['default'] > 0 or ispython:
+ if logger.getEffectiveLevel() <= logging.DEBUG or ispython:
so = os.popen("tee \"%s\"" % logfile, "w")
else:
so = file(logfile, 'w')
- except OSError as e:
- bb.msg.error(bb.msg.domain.Build, "opening log file: %s" % e)
+ except OSError:
+ logger.exception("Opening log file '%s'", logfile)
pass
se = so
@@ -193,7 +198,7 @@ def exec_func(func, d, dirs = None):
se.close()
if os.path.exists(logfile) and os.path.getsize(logfile) == 0:
- bb.msg.debug(2, bb.msg.domain.Build, "Zero size logfile %s, removing" % logfile)
+ logger.debug(2, "Zero size logfile %s, removing", logfile)
os.remove(logfile)
# Close the backup fds
@@ -239,7 +244,8 @@ def exec_func_shell(func, d, runfile, logfile, flags):
f = open(runfile, "w")
f.write("#!/bin/sh -e\n")
- if bb.msg.debug_level['default'] > 0: f.write("set -x\n")
+ if logger.getEffectiveLevel() <= logging.DEBUG:
+ f.write("set -x\n")
data.emit_env(f, d)
f.write("cd %s\n" % os.getcwd())
@@ -275,7 +281,7 @@ def exec_task(task, d):
raise EventException("No such task", InvalidTask(task, d))
try:
- bb.msg.debug(1, bb.msg.domain.Build, "Executing task %s" % task)
+ logger.debug(1, "Executing task %s", task)
old_overrides = data.getVar('OVERRIDES', d, 0)
localdata = data.createCopy(d)
data.setVar('OVERRIDES', 'task-%s:%s' % (task[3:], old_overrides), localdata)
@@ -291,7 +297,7 @@ def exec_task(task, d):
except:
logfile = None
msg = message
- bb.msg.note(1, bb.msg.domain.Build, "Task failed: %s" % message )
+ logger.info("Task failed: %s", message )
failedevent = TaskFailed(msg, logfile, task, d)
event.fire(failedevent, d)
raise EventException("Function failed in task: %s" % message, failedevent)