This document describes the current stable version of Celery (4.3). For development docs, go here.

celery.utils.log

Logging utilities.

class celery.utils.log.ColorFormatter(fmt=None, use_color=True)[source]

Logging formatter that adds colors based on severity.

COLORS = {'black': <bound method colored.black of ''>, 'blue': <bound method colored.blue of ''>, 'cyan': <bound method colored.cyan of ''>, 'green': <bound method colored.green of ''>, 'magenta': <bound method colored.magenta of ''>, 'red': <bound method colored.red of ''>, 'white': <bound method colored.white of ''>, 'yellow': <bound method colored.yellow of ''>}

Loglevel -> Color mapping.

colors = {'CRITICAL': <bound method colored.magenta of ''>, 'DEBUG': <bound method colored.blue of ''>, 'ERROR': <bound method colored.red of ''>, 'WARNING': <bound method colored.yellow of ''>}
format(record)[source]

Format the specified record as text.

The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.

formatException(ei)[source]

Format and return the specified exception information as a string.

This default implementation just uses traceback.print_exception()

class celery.utils.log.LoggingProxy(logger, loglevel=None)[source]

Forward file object to logging.Logger instance.

Parameters:
  • logger (Logger) – Logger instance to forward to.
  • loglevel (int, str) – Log level to use when logging messages.
close()[source]
closed = False
flush()[source]
isatty()[source]

Here for file support.

loglevel = 40
mode = 'w'
name = None
write(data)[source]

Write message to logging object.

writelines(sequence)[source]

Write list of strings to file.

The sequence can be any iterable object producing strings. This is equivalent to calling write() for each string.

celery.utils.log.set_in_sighandler(value)[source]

Set flag signifiying that we’re inside a signal handler.

celery.utils.log.in_sighandler()[source]

Context that records that we are in a signal handler.

celery.utils.log.get_logger(name)[source]

Get logger by name.

celery.utils.log.get_task_logger(name)[source]

Get logger for task module by name.

celery.utils.log.mlevel(level)[source]

Convert level name/int to log level.

celery.utils.log.get_multiprocessing_logger()[source]

Return the multiprocessing logger.

celery.utils.log.reset_multiprocessing_logger()[source]

Reset multiprocessing logging setup.