mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-28 11:55:39 +00:00
Gracefully handle garbage lines at the line cache level
This commit is contained in:
parent
c1c71ec392
commit
a2b332c495
1 changed files with 8 additions and 1 deletions
|
@ -212,6 +212,8 @@ class LineCache (Producer):
|
|||
self.__fileobj.seek (0)
|
||||
limit = self._lines_per_iteration
|
||||
i = 0
|
||||
# TODO: Remove the checks inside this loop. Instead, let exceptions
|
||||
# raise, catch them outside (for performance) and resume the iteration.
|
||||
while True:
|
||||
offset = tell ()
|
||||
line = readline ()
|
||||
|
@ -221,14 +223,19 @@ class LineCache (Producer):
|
|||
# Ignore empty lines, especially the one established by the
|
||||
# final newline at the end:
|
||||
continue
|
||||
if len (line) < ts_len:
|
||||
continue
|
||||
# FIXME: We need to handle foreign lines separately!
|
||||
if line[1] != ":" or line[4] != ":" or line[7] != ".":
|
||||
# No timestamp at start, ignore line:
|
||||
continue
|
||||
|
||||
thread_end = line.find (" ", thread_start)
|
||||
if thread_end == -1 or thread_end + 1 >= len (line):
|
||||
continue
|
||||
offsets.append (offset)
|
||||
levels.append (dict_levels[line[thread_end + 1:thread_end + 2]])
|
||||
level_start = line[thread_end + 1:thread_end + 2]
|
||||
levels.append (dict_levels.get (level_start, debug_level_none))
|
||||
i += 1
|
||||
if i >= limit:
|
||||
i = 0
|
||||
|
|
Loading…
Reference in a new issue