display_distro_statement
[source]
display_distro_statement
(msg
:str
,logger
:Logger
,level
:str
='critical'
)
Display a distro statement
The purpose of this method is to produce a distribution statement in the logger messages. This statement is separated by a line before and after and the message is surrounded by asterisks.
Parameters
msg : str The distribution statement logger : logging.Logger The logger that will be used level : str The logging level. Valid values are 'critical', 'error', 'warning', 'info', and 'debug'. By default 'critical'.
class
Colors
[source]
Colors
()
Data structure containing color codes.
Data structure containing character codes which change text color of a bash terminal of all following characters.
Class Attributes
normal : str Resets text colors in the terminal to default colors black : str Sets text color in terminal to black red : str Sets text color in terminal to red green : str Sets text color in terminal to green yellow : str Sets text color in terminal to yellow blue : str Sets text color in terminal to blue purple : str Sets text color in terminal to purple cyan : str Sets text color in terminal to cyan white : str Sets text color in terminal to white red_highlight : str Sets text background color to red green_highlight : str Sets text background color to green yellow_highlight : str Sets text background color to yellow blue_highlight : str Sets text background color to blue purple_highlight : str Sets text background color to purple cyan_highlight : str Sets text background color to cyan white_highlight : str Sets text background color to white bold : str Sets text thickness larger uline : str Adds an underline to text blink : str Makes the text blink at 1Hz invert : str Inverts the background and text colors
class
ThemeField
[source]
ThemeField
(DEBUG
,INFO
,WARNING
,ERROR
,CRITICAL
)
Various components of a log can have colors edited such as the prompt, message, etc. A message field maps the colors to various log levels and indexed using logging levels.
Attributes
DEBUG: str Str color code defined in Colors class for correcsponding log level INFO: str Str color code defined in Colors class for correcsponding log level WARNING: str Str color code defined in Colors class for correcsponding log level ERROR: str Str color code defined in Colors class for correcsponding log level CRITICAL: str Str color code defined in Colors class for correcsponding log level
Examples
>> field = ThemeField(DEBUG=Colors.green,
INFO=Colors.white,
WARNING=Colors.yellow,
ERROR=Colors.purple,
CRITICAL=Colors.red)
color_text
[source]
color_text
(text
:str
, *colors
:str
)
Applies color to a specific string and appends the color code to set the text to normal. Text can be various colors by adding more args for colors.
Parameters
text: str String to color colors: Tuple[str] Any amount of color codes
Returns
str Input string with each color in colors prepended to the string in order with a Colors.normal trailing.
class
BasicTheme
[source]
BasicTheme
(theme_name
:str
)
The base object used in applying themes. A theme is just a collection of ThemeField objects for different portions of the output log. This class is meant to be inherited from for other themes and the desired fields overwritten with new colors.
Class Attributes
Themes A list of every theme. This allows for themes to be gotten globally.
class
BasicColorTheme
[source]
BasicColorTheme
(theme_name
='color_theme'
) ::BasicTheme
Theme for basic colored output where the logging level text is the same color as the log message. This class is a good example for how to create new themes by inheriting from the basic theme. The derived themes if any field is not overwritten just stays the same as the default one.
class
AlignedColorFormatter
[source]
AlignedColorFormatter
(theme
:BasicTheme
) ::Formatter
Logging formatter to display aligned meta data of date with ms time stamp, logger name, line number, and log level.