helperFunctions.logging module
- class helperFunctions.logging.ColoringFormatter(fmt=None, datefmt=None, style='%', validate=True)
Bases:
Formatter
A subclass of
Formatter
that automatically prints the log level in the respective color.- LOG_LEVEL_COLORS = [('DEBUG', '\x1b[95m'), ('INFO', '\x1b[94m'), ('WARNING', '\x1b[93m'), ('ERROR', '\x1b[91m'), ('CRITICAL', '\x1b[91m\x1b[1m')]
A List of Tuples with log levels and colors/formatting.
- format(record)
Format the specified record as text. The log level is colored in the respective color from
TerminalColors
as defined inLOG_LEVEL_COLORS
.- Parameters:
record (LogRecord) –
- Return type:
str
- class helperFunctions.logging.TerminalColors
Bases:
object
This class contains colors and formatting used for formatting the terminal output. A the terminal output after a string from this class will be colored in the respective color.
ENDC
must be used to stop formatting the output.- BLUE = '\x1b[94m'
- BOLD = '\x1b[1m'
- ENDC = '\x1b[0m'
- FAIL = '\x1b[91m'
- GREEN = '\x1b[92m'
- HEADER = '\x1b[95m'
- OKBLUE = '\x1b[94m'
- OKGREEN = '\x1b[92m'
- PURPLE = '\x1b[95m'
- RED = '\x1b[91m'
- UNDERLINE = '\x1b[4m'
- WARNING = '\x1b[93m'
- YELLOW = '\x1b[93m'
- helperFunctions.logging.color_string(string, color)
Format a string in a color from
TerminalColors
for terminal output.- Parameters:
string (str) – The string that will be colored.
color (str) – A color from
TerminalColors
or any other terminal compatible formatting string.
- Returns:
The formatted string.
- Return type:
str