pelagos_py.utils.console#

class pelagos_py.utils.console.LogFormatter(datefmt='%H:%M:%S', color=False)[source]#

Bases: logging.Formatter

Format a record as time  name  message, for the console and the log file.

The name is the step or process the logger belongs to, padded or cut to one width so the messages line up. Warning-and-above lines get a tag (WARN, SEVERE, ERROR, STOP) before the message, coloured if color. Pass extra={"raw": True} to emit a line verbatim.

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.

pelagos_py.utils.console.make_console_handler(level=logging.INFO)[source]#

Build the pipeline’s console handler: compact, coloured, tqdm-aware.

pelagos_py.utils.console.progress_bar(iterable=None, *, desc='', total=None, unit='it', leave=False, logger=None, step_name=None)[source]#

A tqdm bar in the pipeline’s standard style for every countable loop.

step_name adds the time  name prefix; logger also writes a one-line summary to the file. Auto-disables off a terminal.