prefect.server.logs.stream

Log streaming for live log distribution via websockets.

Functions

subscribed

subscribed(filter: LogFilter) -> AsyncGenerator['Queue[Log]', None]
Subscribe to a stream of logs matching the given filter. Args:
  • filter: The log filter to apply

logs

logs(filter: LogFilter) -> AsyncGenerator[AsyncIterable[Log | None], None]
Create a stream of logs matching the given filter. Args:
  • filter: The log filter to apply

log_matches_filter

log_matches_filter(log: Log, filter: LogFilter) -> bool
Check if a log matches the given filter criteria. Args:
  • log: The log to check
  • filter: The filter to apply
Returns:
  • True if the log matches the filter, False otherwise

distributor

distributor() -> AsyncGenerator[messaging.MessageHandler, None]
Create a message handler that distributes logs to subscribed clients.

start_distributor

start_distributor() -> None
Starts the distributor consumer as a global background task

stop_distributor

stop_distributor() -> None
Stops the distributor consumer global background task

run_distributor

run_distributor(started: asyncio.Event) -> NoReturn
Runs the distributor consumer forever until it is cancelled

Classes

LogDistributor

Service for distributing logs to websocket subscribers Methods:

all_services

all_services(cls) -> Sequence[type[Self]]
Get list of all service classes

enabled

enabled(cls) -> bool

enabled

enabled(cls) -> bool
Whether the service is enabled

enabled_services

enabled_services(cls) -> list[type[Self]]
Get list of enabled service classes

environment_variable_name

environment_variable_name(cls) -> str

environment_variable_name

environment_variable_name(cls) -> str

run_services

run_services(cls) -> NoReturn
Run enabled services until cancelled.

running

running(cls) -> AsyncGenerator[None, None]
A context manager that runs enabled services on entry and stops them on exit.

service_settings

service_settings(cls) -> ServicesBaseSetting

service_settings

service_settings(cls) -> ServicesBaseSetting
The Prefect setting that controls whether the service is enabled

start

start(self) -> NoReturn

start

start(self) -> NoReturn
Start running the service, which may run indefinitely

stop

stop(self) -> None

stop

stop(self) -> None
Stop the service