prefect.logging.handlers

Classes

APILogWorker

Methods:

instance

instance(cls: Type[Self], *args: Any) -> Self

max_batch_size

max_batch_size(self) -> int

min_interval

min_interval(self) -> float | None

APILogHandler

A logging handler that sends logs to the Prefect API. Sends log records to the APILogWorker which manages sending batches of logs in the background. Methods:

aflush

aflush(cls) -> None
Tell the APILogWorker to send any currently enqueued logs and block until completion.

emit

emit(self, record: logging.LogRecord) -> None
Send a log to the APILogWorker

flush

flush(self) -> None
Tell the APILogWorker to send any currently enqueued logs and block until completion. Use aflush from async contexts instead.

handleError

handleError(self, record: logging.LogRecord) -> None

prepare

prepare(self, record: logging.LogRecord) -> Dict[str, Any]
Convert a logging.LogRecord to the API LogCreate schema and serialize. This infers the linked flow or task run from the log record or the current run context. If a flow run id cannot be found, the log will be dropped. Logs exceeding the maximum size will be dropped.

WorkerAPILogHandler

Methods:

aflush

aflush(cls) -> None
Tell the APILogWorker to send any currently enqueued logs and block until completion.

emit

emit(self, record: logging.LogRecord) -> None

emit

emit(self, record: logging.LogRecord) -> None
Send a log to the APILogWorker

flush

flush(self) -> None
Tell the APILogWorker to send any currently enqueued logs and block until completion. Use aflush from async contexts instead.

handleError

handleError(self, record: logging.LogRecord) -> None

prepare

prepare(self, record: logging.LogRecord) -> Dict[str, Any]
Convert a logging.LogRecord to the API LogCreate schema and serialize. This will add in the worker id to the log. Logs exceeding the maximum size will be dropped.

prepare

prepare(self, record: logging.LogRecord) -> Dict[str, Any]
Convert a logging.LogRecord to the API LogCreate schema and serialize. This infers the linked flow or task run from the log record or the current run context. If a flow run id cannot be found, the log will be dropped. Logs exceeding the maximum size will be dropped.

PrefectConsoleHandler

Methods:

emit

emit(self, record: logging.LogRecord) -> None