This will handle invalid message types like the one that triggers the
KeyError in dblink._elog_process for bug #390833. It will also output
the content of the line in order to help diagnose the source of
corruption.
import io
import sys
+_log_levels = frozenset([
+ "ERROR",
+ "INFO",
+ "LOG",
+ "QA",
+ "WARN",
+])
+
def collect_ebuild_messages(path):
""" Collect elog messages generated by the bash logging function stored
at 'path'.
continue
try:
msgtype, msg = l.split(" ", 1)
+ if msgtype not in _log_levels:
+ raise ValueError(msgtype)
except ValueError:
writemsg(_("!!! malformed entry in "
- "log file: '%s'\n") % filename, noiselevel=-1)
+ "log file: '%s': %s\n") % (filename, l), noiselevel=-1)
continue
if lastmsgtype is None: