summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2018-11-27 11:31:21 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-11-27 22:15:34 +0000
commit1b04525d3f7b80d82ef1b98fa788296c04e48a7b (patch)
tree8a7ba6dd75710e13fbf28228175091cb3160b612
parenta834889120eb76ffb5df21c2ba34fff0dddb67b1 (diff)
downloadpoky-1b04525d3f7b80d82ef1b98fa788296c04e48a7b.tar.gz
bitbake: server/process: Show last 60 lines of the log if the server didn't start
We're seeing issues where the server doesn't start with no logs as to why. Allow the server to print the last 60 log lines just in case this shows us something useful about what is failing. (Bitbake rev: c8c80b404e38fe96f65d6314cd95f4069319f3d6) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/server/process.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py
index 4e0d9c2dbc..38a62fa34e 100644
--- a/bitbake/lib/bb/server/process.py
+++ b/bitbake/lib/bb/server/process.py
@@ -412,22 +412,28 @@ class BitBakeServer(object):
412 logstart_re = re.compile(self.start_log_format % ('([0-9]+)', '([0-9-]+ [0-9:.]+)')) 412 logstart_re = re.compile(self.start_log_format % ('([0-9]+)', '([0-9-]+ [0-9:.]+)'))
413 started = False 413 started = False
414 lines = [] 414 lines = []
415 lastlines = []
415 with open(logfile, "r") as f: 416 with open(logfile, "r") as f:
416 for line in f: 417 for line in f:
417 if started: 418 if started:
418 lines.append(line) 419 lines.append(line)
419 else: 420 else:
421 lastlines.append(line)
420 res = logstart_re.match(line.rstrip()) 422 res = logstart_re.match(line.rstrip())
421 if res: 423 if res:
422 ldatetime = datetime.datetime.strptime(res.group(2), self.start_log_datetime_format) 424 ldatetime = datetime.datetime.strptime(res.group(2), self.start_log_datetime_format)
423 if ldatetime >= startdatetime: 425 if ldatetime >= startdatetime:
424 started = True 426 started = True
425 lines.append(line) 427 lines.append(line)
428 if len(lastlines) > 60:
429 lastlines = lastlines[-60:]
426 if lines: 430 if lines:
427 if len(lines) > 10: 431 if len(lines) > 10:
428 bb.error("Last 10 lines of server log for this session (%s):\n%s" % (logfile, "".join(lines[-10:]))) 432 bb.error("Last 10 lines of server log for this session (%s):\n%s" % (logfile, "".join(lines[-10:])))
429 else: 433 else:
430 bb.error("Server log for this session (%s):\n%s" % (logfile, "".join(lines))) 434 bb.error("Server log for this session (%s):\n%s" % (logfile, "".join(lines)))
435 elif lastlines:
436 bb.error("Server didn't start, last 60 loglines (%s):\n%s" % (logfile, "".join(lastlines)))
431 else: 437 else:
432 bb.error("%s doesn't exist" % logfile) 438 bb.error("%s doesn't exist" % logfile)
433 439