Skip to main content

StreamedLog

Streams Actor run log output to a Python logger in a background thread.

The log stream is consumed in a background thread and each log message is forwarded to the provided logger with an appropriate log level inferred from the message content.

Can be used as a context manager, which automatically starts and stops the streaming thread. Alternatively, call start and stop manually. Obtain an instance via RunClient.get_streamed_log.

Hierarchy

Index

Methods

__enter__

  • __enter__(): Self
  • Start the streaming thread within the context. Exiting the context will finish the streaming thread.


    Returns Self

__exit__

  • __exit__(exc_type, exc_val, exc_tb): None
  • Stop the streaming thread.


    Parameters

    • exc_type: type[BaseException] | None
    • exc_val: BaseException | None
    • exc_tb: TracebackType | None

    Returns None

__init__

  • __init__(log_client, *, to_logger, from_start): None
  • Initialize StreamedLog.


    Parameters

    • log_client: LogClient

      The log client used to stream raw log data from the Actor run.

    • keyword-onlyto_logger: logging.Logger

      The logger to which the log messages will be forwarded.

    • optionalkeyword-onlyfrom_start: bool = True

      If True, all logs from the start of the Actor run will be streamed. If False, only newly arrived logs will be streamed. This can be useful for long-running Actors in stand-by mode where only recent logs are relevant.

    Returns None

start

  • start(): Thread
  • Start the streaming thread.

    The caller is responsible for cleanup by calling the stop method when done.


    Returns Thread

stop

  • stop(): None
  • Signal the streaming thread to stop logging and wait for it to finish.


    Returns None

Page Options