otupy.utils.log_formatting.LogFormatter
- class LogFormatter(datetime=True, name=True, datefmt=None)
Bases:
FormatterColored logging formatter
The colormap is fixed, but the user can select which fields to include: - datetime: date and time of the log - module name: the name of the module that generated the log The level and message are always included and cannot be omitted.
Methods
localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,
Color the record according to the log level
Format and return the specified exception information as a string.
formatMessageThis method is provided as an extension point for specialized formatting of stack information.
This function is invoked when (asctime) is used in the format string
Check if the format uses the creation time of the record.
Attributes
bluedefault_msec_formatdefault_time_formatgreengreyhighlight_redredresetyellow- __init__(datetime=True, name=True, datefmt=None)
Set the custom format
Select which optional fields will be included. :param datetime: Set to False to disable date/time indication. :param name: Set to False to diable module name indication. :param datefmt: Format the date according to this string. Takes common
time.strftime specifiers, plus the ‘%t’ which gives the timestamp.
- converter()
- localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,
tm_sec,tm_wday,tm_yday,tm_isdst)
Convert seconds since the Epoch to a time tuple expressing local time. When ‘seconds’ is not passed in, convert the current time instead.
- format(record)
Color the record according to the log level
- formatException(ei)
Format and return the specified exception information as a string.
This default implementation just uses traceback.print_exception()
- formatStack(stack_info)
This method is provided as an extension point for specialized formatting of stack information.
The input data is a string as returned from a call to
traceback.print_stack(), but with the last trailing newline removed.The base implementation just returns the value passed in.
- formatTime(datefmt=None)
This function is invoked when (asctime) is used in the format string
- usesTime()
Check if the format uses the creation time of the record.