Skip to main content

TaskFormatter

Formatter for tasks, adding the task name and id.

Methods


format()

@classmethod
def format(
record: LogRecord
) - > string

Formats the specified log record by injecting the current Celery task's name and ID into the record's attributes. This ensures that log messages include task-specific context for easier debugging and tracking of asynchronous executions.

Parameters

NameTypeDescription
recordLogRecordThe logging record object containing the message and metadata to be formatted.

Returns

TypeDescription
stringThe formatted log message string, including task metadata and colorization from the parent formatter.