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.StreamReader originating 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 an INFO message with generic metadata.

Parameters:
  • stream (asyncio.StreamReader) – An asynchronous stream to read from, usually proc.stdout or proc.stderr from asyncio.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), both file.name and file.path will be set accordingly in the forwarded Loguru log entry.

  • If metadata cannot be extracted, fallback values (subprocess.py and /subprocess/subprocess.py) are used.

  • The function runs until stream reaches EOF.