Skip to contentSkip to conversation

server/process: Show last 60 lines of the log if the server didn't start

PATCH New Richard Purdie 1 participant 3 messages Nov 27, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 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.

---
 lib/bb/server/process.py | 6 ++++++
 1 file changed, 6 insertions(+)
lib/bb/server/process.py +6 -0
index 4e0d9c2dbc..38a62fa34e 100644
@@ -412,22 +412,28 @@ class BitBakeServer(object):
                 logstart_re = re.compile(self.start_log_format % ('([0-9]+)', '([0-9-]+ [0-9:.]+)'))
                 started = False
                 lines = []
+                lastlines = []
                 with open(logfile, "r") as f:
                     for line in f:
                         if started:
                             lines.append(line)
                         else:
+                            lastlines.append(line)
                             res = logstart_re.match(line.rstrip())
                             if res:
                                 ldatetime = datetime.datetime.strptime(res.group(2), self.start_log_datetime_format)
                                 if ldatetime >= startdatetime:
                                     started = True
                                     lines.append(line)
+                        if len(lastlines) > 60:
+                            lastlines = lastlines[-60:]
                 if lines:
                     if len(lines) > 10:
                         bb.error("Last 10 lines of server log for this session (%s):\n%s" % (logfile, "".join(lines[-10:])))
                     else:
                         bb.error("Server log for this session (%s):\n%s" % (logfile, "".join(lines)))
+                elif lastlines:
+                        bb.error("Server didn't start, last 60 loglines (%s):\n%s" % (logfile, "".join(lastlines)))
             else:
                 bb.error("%s doesn't exist" % logfile)
 
Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/3 server/process: Show the last 60 log lines, not the last 10

10 log lines may not capture any full traceback, increase the number of lines to 60 which covers most tracebacks.

---
 lib/bb/server/process.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/bb/server/process.py +2 -2
index 38a62fa34e..efb4332394 100644
@@ -428,8 +428,8 @@ class BitBakeServer(object):
                         if len(lastlines) > 60:
                             lastlines = lastlines[-60:]
                 if lines:
-                    if len(lines) > 10:
-                        bb.error("Last 10 lines of server log for this session (%s):\n%s" % (logfile, "".join(lines[-10:])))
+                    if len(lines) > 60:
+                        bb.error("Last 60 lines of server log for this session (%s):\n%s" % (logfile, "".join(lines[-60:])))
                     else:
                         bb.error("Server log for this session (%s):\n%s" % (logfile, "".join(lines)))
                 elif lastlines:
Signature · 1 line
2.17.1
#2 lore raw

PATCH 3/3 fetch2: Avoid warning about incorrect character escaping in regex

In reply to Richard Purdie

Fixes:

lib/bb/fetch2/__init__.py:259: DeprecationWarning: invalid escape sequence \w
re.compile("^\w+:(?!//)").match(uri):

---
 lib/bb/fetch2/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/fetch2/__init__.py +1 -1
index 8d05f0c3d8..709372e16f 100644
@@ -256,7 +256,7 @@ class URI(object):
 
         # Identify if the URI is relative or not
         if urlp.scheme in self._relative_schemes and \
-           re.compile("^\w+:(?!//)").match(uri):
+           re.compile(r"^\w+:(?!//)").match(uri):
             self.relative = True
 
         if not self.relative:
Signature · 1 line
2.17.1