mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +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)
|
self.__fileobj.seek (0)
|
||||||
limit = self._lines_per_iteration
|
limit = self._lines_per_iteration
|
||||||
i = 0
|
i = 0
|
||||||
|
# TODO: Remove the checks inside this loop. Instead, let exceptions
|
||||||
|
# raise, catch them outside (for performance) and resume the iteration.
|
||||||
while True:
|
while True:
|
||||||
offset = tell ()
|
offset = tell ()
|
||||||
line = readline ()
|
line = readline ()
|
||||||
|
@ -221,14 +223,19 @@ class LineCache (Producer):
|
||||||
# Ignore empty lines, especially the one established by the
|
# Ignore empty lines, especially the one established by the
|
||||||
# final newline at the end:
|
# final newline at the end:
|
||||||
continue
|
continue
|
||||||
|
if len (line) < ts_len:
|
||||||
|
continue
|
||||||
# FIXME: We need to handle foreign lines separately!
|
# FIXME: We need to handle foreign lines separately!
|
||||||
if line[1] != ":" or line[4] != ":" or line[7] != ".":
|
if line[1] != ":" or line[4] != ":" or line[7] != ".":
|
||||||
# No timestamp at start, ignore line:
|
# No timestamp at start, ignore line:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
thread_end = line.find (" ", thread_start)
|
thread_end = line.find (" ", thread_start)
|
||||||
|
if thread_end == -1 or thread_end + 1 >= len (line):
|
||||||
|
continue
|
||||||
offsets.append (offset)
|
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
|
i += 1
|
||||||
if i >= limit:
|
if i >= limit:
|
||||||
i = 0
|
i = 0
|
||||||
|
|
Loading…
Reference in a new issue