akkudoktoreos.server.rest.starteosdash.forward_stream
- async akkudoktoreos.server.rest.starteosdash.forward_stream(stream: StreamReader, prefix: str = '') None
Continuously read log lines from a subprocess and re-log them via Loguru.
The function reads lines from an
asyncio.StreamReaderoriginating from a subprocess (typically the subprocess’s stdout or stderr), parses the log metadata if present (log level, file path, line number, function), and forwards the log entry to Loguru. If the line cannot be parsed, it is logged as anINFOmessage with generic metadata.- Parameters:
stream (asyncio.StreamReader) – An asynchronous stream to read from, usually
proc.stdoutorproc.stderrfromasyncio.create_subprocess_exec.prefix (str, optional) – A string prefix added to each forwarded log line. Useful for distinguishing between multiple subprocess sources. Defaults to an empty string.
Notes
If the subprocess log line includes a file path (e.g.,
/app/server/main.py:42), bothfile.nameandfile.pathwill be set accordingly in the forwarded Loguru log entry.If metadata cannot be extracted, fallback values (
subprocess.pyand/subprocess/subprocess.py) are used.The function runs until
streamreaches EOF.