pelagos_py.utils.log_levels#

pelagos_py.utils.log_levels.STOP = 45[source]#

Custom log level for a deliberate pipeline halt (e.g. invalid config).

Sits just above ERROR so it always surfaces, and is rendered as “STOP” in logs.

class pelagos_py.utils.log_levels.ColorFormatter(*args, stream=None, **kwargs)[source]#

Bases: logging.Formatter

Formatter that colours records by level on the console (STOP/ERROR red, WARNING yellow).

Colour is only emitted when the target stream is an interactive terminal that supports it (see _supports_color()), so redirected output and dumb terminals stay clean plain text. Intended for stream handlers only; the file handler keeps a plain formatter so log files carry no escape codes.

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.