The logging facility.

Module Contents

thepipe.logger.DEPRECATION = 45[source]
thepipe.logger.ONCE = 46[source]
thepipe.logger.DATEFMT = %Y-%m-%d %H:%M:%S[source]
thepipe.logger.deprecation(self, message, *args, **kwargs)[source]

Show a deprecation warning.

thepipe.logger.once(self, message, *args, identifier=None, **kwargs)[source]

Show a message only once, determined by position in source or identifer.

This will not work in IPython or Jupyter notebooks if no identifier is specified, since then the determined position in source contains the execution number of the input (cell), which changes every time. Set a unique identifier, otherwise the message will be printed every time.


Create escaped code from format code

thepipe.logger.COLORS = ['black', 'red', 'green', 'yellow', 'blue', 'purple', 'cyan', 'white'][source]
thepipe.logger.PREFIXES = [['3', ''], ['01;3', 'bold_'], ['02;3', 'thin_'], ['3', 'fg_'], ['01;3', 'fg_bold_'], ['02;3', 'fg_thin_'], ['4', 'bg_'], ['10', 'bg_bold_']][source]

Return escape codes from a color sequence.

class thepipe.logger.ColoredRecord(record)[source]

Wraps a LogRecord, adding named escape codes to the internal dict. The internal dict is used when formatting the message (by the PercentStyle, StrFormatStyle, and StringTemplateStyle classes).

class thepipe.logger.ColouredFormatter(fmt, datefmt=None, style='%', log_colors=None, reset=True, secondary_log_colors=None)[source]

Bases: logging.Formatter

A formatter that allows colors to be placed in the format string. Intended to help in creating more readable logging output.

Based on

format(self, record)[source]

Format a message from a record object.

thepipe.logger.get_logger(name, filename=None, datefmt=DATEFMT)[source]

Helper function to get a logger.

If a filename is specified, it will also log to that file.


Return a list of avialable logger names

thepipe.logger.set_level(name, level)[source]

Set the log level for given logger

thepipe.logger.get_printer(name, color=None, ansi_code=None, force_color=False)[source]

Return a function which prints a message with a coloured name prefix

thepipe.logger.escape_codes(log_colors, level_name)[source]

Return escape codes from a log_colors dict.


Return a ANSI coloured text based on its hash


Return the ANSI hash colour prefix and suffix for a given text