Skip to content

Commit

Permalink
Improved XML output stream detection! (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
mindstorm38 committed Apr 16, 2024
1 parent edb1d44 commit c33be61
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions portablemc/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -1622,14 +1622,14 @@ def process_stream_thread(self, process: Popen) -> None:
stdout = process.stdout
assert stdout is not None, "should not be none because it should be piped"

parser = None
parser = StreamParser()
for line in iter(stdout.readline, ""):

if parser is None:
if line.lstrip().startswith("<log4j:"):
parser = XmlStreamParser()
else:
parser = StreamParser()
# By default the parser is raw but if we encounter any potential XML tag we
# set the parser to the XML one and starting parsing. If it fails immediately
# then it reset it to a raw stream parser.
if line.lstrip().startswith("<log4j:") and not isinstance(parser, XmlStreamParser):
parser = XmlStreamParser()

if not parser.feed(line, self.process_stream_event):
parser = StreamParser()
Expand Down

0 comments on commit c33be61

Please sign in to comment.