thepipe.logger
¶
The logging facility.
Module Contents¶
-
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.
-
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]¶
-
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.
-
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.
-
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