summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbitbake/bin/bitbake5
-rw-r--r--bitbake/lib/bb/event.py18
-rw-r--r--bitbake/lib/bb/runqueue.py10
-rw-r--r--bitbake/lib/bb/ui/knotty.py72
4 files changed, 57 insertions, 48 deletions
diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake
index 9b2cfdf5c5..a80c01ca50 100755
--- a/bitbake/bin/bitbake
+++ b/bitbake/bin/bitbake
@@ -164,7 +164,8 @@ Default BBFILES are the .bb files in the current directory.""")
164 configuration.pkgs_to_build.extend(args[1:]) 164 configuration.pkgs_to_build.extend(args[1:])
165 configuration.initial_path = os.environ['PATH'] 165 configuration.initial_path = os.environ['PATH']
166 166
167 logger.addHandler(event.LogHandler()) 167 loghandler = event.LogHandler()
168 logger.addHandler(loghandler)
168 169
169 #server = bb.server.xmlrpc 170 #server = bb.server.xmlrpc
170 server = bb.server.none 171 server = bb.server.none
@@ -190,6 +191,8 @@ Default BBFILES are the .bb files in the current directory.""")
190 server.BitBakeServerFork(cooker, cooker.server, serverinfo, cooker_logfile) 191 server.BitBakeServerFork(cooker, cooker.server, serverinfo, cooker_logfile)
191 del cooker 192 del cooker
192 193
194 logger.removeHandler(loghandler)
195
193 # Setup a connection to the server (cooker) 196 # Setup a connection to the server (cooker)
194 serverConnection = server.BitBakeServerConnection(serverinfo) 197 serverConnection = server.BitBakeServerConnection(serverinfo)
195 198
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index c04ffd5ac1..3fb9ff5bfc 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -328,20 +328,8 @@ class MsgPlain(MsgBase):
328class LogHandler(logging.Handler): 328class LogHandler(logging.Handler):
329 """Dispatch logging messages as bitbake events""" 329 """Dispatch logging messages as bitbake events"""
330 330
331 messages = (
332 (logging.DEBUG, MsgDebug),
333 (logging.INFO, MsgNote),
334 (logging.WARNING, MsgWarn),
335 (logging.ERROR, MsgError),
336 (logging.CRITICAL, MsgFatal),
337 )
338
339 def emit(self, record): 331 def emit(self, record):
340 for level, msgclass in self.messages: 332 fire(record, None)
341 if record.levelno <= level: 333 if bb.event.useStdout:
342 msg = self.format(record) 334 print(self.format(record))
343 fire(msgclass(msg), None)
344 if bb.event.useStdout:
345 print(record.levelname + ": " + record.getMessage())
346 break
347 335
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py
index be873ff7dc..94b456a988 100644
--- a/bitbake/lib/bb/runqueue.py
+++ b/bitbake/lib/bb/runqueue.py
@@ -24,11 +24,14 @@ Handles preparation and execution of a queue of tasks
24 24
25import bb, os, sys 25import bb, os, sys
26import subprocess 26import subprocess
27from bb import msg, data, event
28import signal 27import signal
29import stat 28import stat
30import fcntl 29import fcntl
31import copy 30import copy
31import logging
32from bb import msg, data, event
33
34bblogger = logging.getLogger("BitBake")
32 35
33try: 36try:
34 import cPickle as pickle 37 import cPickle as pickle
@@ -1127,6 +1130,11 @@ class RunQueueExecute:
1127 bb.event.worker_pipe = pipeout 1130 bb.event.worker_pipe = pipeout
1128 bb.event.useStdout = False 1131 bb.event.useStdout = False
1129 1132
1133 # Child processes should send their messages to the UI
1134 # process via the server process, not print them
1135 # themselves
1136 bblogger.handlers = [bb.event.LogHandler()]
1137
1130 self.rq.state = runQueueChildProcess 1138 self.rq.state = runQueueChildProcess
1131 # Make the child the process group leader 1139 # Make the child the process group leader
1132 os.setpgid(0, 0) 1140 os.setpgid(0, 0)
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index 9162c79f6a..177a12609c 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -24,12 +24,22 @@ import os
24import sys 24import sys
25import itertools 25import itertools
26import xmlrpclib 26import xmlrpclib
27import logging
27from bb import ui 28from bb import ui
28from bb.ui import uihelper 29from bb.ui import uihelper
29 30
30 31logger = logging.getLogger("BitBake")
31parsespin = itertools.cycle( r'|/-\\' ) 32parsespin = itertools.cycle( r'|/-\\' )
32 33
34class BBLogFormatter(logging.Formatter):
35 """Formatter which ensures that our 'plain' messages (logging.INFO + 1) are used as is"""
36
37 def format(self, record):
38 if record.levelno == logging.INFO + 1:
39 return record.getMessage()
40 else:
41 return logging.Formatter.format(self, record)
42
33def init(server, eventHandler): 43def init(server, eventHandler):
34 44
35 # Get values of variables which control our output 45 # Get values of variables which control our output
@@ -38,9 +48,23 @@ def init(server, eventHandler):
38 48
39 helper = uihelper.BBUIHelper() 49 helper = uihelper.BBUIHelper()
40 50
51 # Set up logging to stdout in our usual format
52 logging.addLevelName(logging.INFO, "NOTE")
53 logging.addLevelName(logging.CRITICAL, "FATAL")
54
55 for level in xrange(logging.INFO - 1, logging.DEBUG + 1, -1):
56 logging.addLevelName(level, logging.getLevelName(logging.INFO))
57
58 for level in xrange(logging.DEBUG - 1, 0, -1):
59 logging.addLevelName(level, logging.getLevelName(logging.DEBUG))
60
61 console = logging.StreamHandler(sys.stdout)
62 format = BBLogFormatter("%(levelname)s: %(message)s")
63 console.setFormatter(format)
64 logger.addHandler(console)
65
41 try: 66 try:
42 cmdline = server.runCommand(["getCmdLineAction"]) 67 cmdline = server.runCommand(["getCmdLineAction"])
43 #print cmdline
44 if not cmdline: 68 if not cmdline:
45 return 1 69 return 1
46 ret = server.runCommand(cmdline) 70 ret = server.runCommand(cmdline)
@@ -58,7 +82,6 @@ def init(server, eventHandler):
58 event = eventHandler.waitEvent(0.25) 82 event = eventHandler.waitEvent(0.25)
59 if event is None: 83 if event is None:
60 continue 84 continue
61 #print event
62 helper.eventHandler(event) 85 helper.eventHandler(event)
63 if isinstance(event, bb.runqueue.runQueueExitWait): 86 if isinstance(event, bb.runqueue.runQueueExitWait):
64 if not shutdown: 87 if not shutdown:
@@ -72,26 +95,13 @@ def init(server, eventHandler):
72 print("%s: %s (pid %s)" % (tasknum, activetasks[task]["title"], task)) 95 print("%s: %s (pid %s)" % (tasknum, activetasks[task]["title"], task))
73 tasknum = tasknum + 1 96 tasknum = tasknum + 1
74 97
75 if isinstance(event, bb.event.MsgPlain): 98 if isinstance(event, logging.LogRecord):
76 print(event._message) 99 if event.levelno is logging.CRITICAL or event.levelno is logging.ERROR:
77 continue 100 return_value = 1
78 if isinstance(event, bb.event.MsgDebug): 101 if isinstance(event, logging.LogRecord):
79 print('DEBUG: ' + event._message) 102 logger.handle(event)
80 continue
81 if isinstance(event, bb.event.MsgNote):
82 print('NOTE: ' + event._message)
83 continue
84 if isinstance(event, bb.event.MsgWarn):
85 print('WARNING: ' + event._message)
86 continue
87 if isinstance(event, bb.event.MsgError):
88 return_value = 1
89 print('ERROR: ' + event._message)
90 continue
91 if isinstance(event, bb.event.MsgFatal):
92 return_value = 1
93 print('FATAL: ' + event._message)
94 continue 103 continue
104
95 if isinstance(event, bb.build.TaskFailed): 105 if isinstance(event, bb.build.TaskFailed):
96 return_value = 1 106 return_value = 1
97 logfile = event.logfile 107 logfile = event.logfile
@@ -117,7 +127,7 @@ def init(server, eventHandler):
117 for line in lines: 127 for line in lines:
118 print(line) 128 print(line)
119 if isinstance(event, bb.build.TaskBase): 129 if isinstance(event, bb.build.TaskBase):
120 print("NOTE: %s" % event._message) 130 logger.info(event._message)
121 continue 131 continue
122 if isinstance(event, bb.event.ParseProgress): 132 if isinstance(event, bb.event.ParseProgress):
123 x = event.sofar 133 x = event.sofar
@@ -144,15 +154,15 @@ def init(server, eventHandler):
144 continue 154 continue
145 if isinstance(event, bb.command.CookerCommandFailed): 155 if isinstance(event, bb.command.CookerCommandFailed):
146 return_value = 1 156 return_value = 1
147 print("Command execution failed: %s" % event.error) 157 logger.error("Command execution failed: %s" % event.error)
148 break 158 break
149 if isinstance(event, bb.cooker.CookerExit): 159 if isinstance(event, bb.cooker.CookerExit):
150 break 160 break
151 if isinstance(event, bb.event.MultipleProviders): 161 if isinstance(event, bb.event.MultipleProviders):
152 print("NOTE: multiple providers are available for %s%s (%s)" % (event._is_runtime and "runtime " or "", 162 logger.info("multiple providers are available for %s%s (%s)", event._is_runtime and "runtime " or "",
153 event._item, 163 event._item,
154 ", ".join(event._candidates))) 164 ", ".join(event._candidates))
155 print("NOTE: consider defining a PREFERRED_PROVIDER entry to match %s" % event._item) 165 logger.info("consider defining a PREFERRED_PROVIDER entry to match %s", event._item)
156 continue 166 continue
157 if isinstance(event, bb.event.NoProvider): 167 if isinstance(event, bb.event.NoProvider):
158 if event._runtime: 168 if event._runtime:
@@ -161,9 +171,9 @@ def init(server, eventHandler):
161 r = "" 171 r = ""
162 172
163 if event._dependees: 173 if event._dependees:
164 print("ERROR: Nothing %sPROVIDES '%s' (but %s %sDEPENDS on or otherwise requires it)" % (r, event._item, ", ".join(event._dependees), r)) 174 logger.error("Nothing %sPROVIDES '%s' (but %s %sDEPENDS on or otherwise requires it)", r, event._item, ", ".join(event._dependees), r)
165 else: 175 else:
166 print("ERROR: Nothing %sPROVIDES '%s'" % (r, event._item)) 176 logger.error("Nothing %sPROVIDES '%s'", r, event._item)
167 continue 177 continue
168 178
169 # ignore 179 # ignore
@@ -175,7 +185,7 @@ def init(server, eventHandler):
175 bb.runqueue.runQueueExitWait)): 185 bb.runqueue.runQueueExitWait)):
176 continue 186 continue
177 187
178 print("Unknown Event: %s" % event) 188 logger.error("Unknown event: %s", event)
179 189
180 except KeyboardInterrupt: 190 except KeyboardInterrupt:
181 if shutdown == 2: 191 if shutdown == 2: