scenario.logformatter module¶
Log record formatting.
- class LogFormatter¶
Bases:
FormatterFormats log records.
Log record formatting includes the following aspects:
- Date/time display:
See log date/time documentation.
Displayed by default, unless it is disabled through the
ScenarioConfig.Key.LOG_DATETIMEconfiguration, or theExtraFlag.DATE_TIMEextra flag.- Log level display:
See log levels documentation.
Log level is always displayed, unless it is disabled through the
ExtraFlag.LOG_LEVELextra flag.- Date/time display:
See log date/time documentation.
Displayed by default, unless it is disabled through the
ScenarioConfig.Key.LOG_DATETIMEconfiguration, or theExtraFlag.DATE_TIMEextra flag.- Log level display:
See log levels documentation.
Log level is always displayed, unless it is disabled through the
ExtraFlag.LOG_LEVELextra flag.- Log class display:
See class loggers documentation.
- Indentation:
See log indentation documentation.
- Colorization:
See log colors documentation.
Console log colorization may be disabled through the
ScenarioConfig.Key.LOG_CONSOLEconfiguration, or theExtraFlag.COLORextra flag.
- __init__(handler)¶
- Parameters:
handler – Attached
logging.Handler.
- _handler¶
Attached
logging.Handler.
- format(record)¶
loggingmethod overload that implements most of the scenario log formatting expectations.- Parameters:
record – Log record to format for printing.
- Returns:
Log string representation.
- _with(record, extra_flag, default=True)¶
Tells whether the logging aspect described by
extra_flagis on or off for the given record.- Parameters:
extra_flag – Extra flag / logging aspect to check.
default – Default return value. May be set to
Falsewhen required.
- Returns:
Trueif the logging aspect described byextra_flagin on for the current record,Falseotherwise.
Depends on :
The extra flags set in the log record,
The scenario configuration,
The current execution state.
- static _levelcolor(level)¶
Determines log color out from log level.
- Parameters:
level – Log level which respective color to find out.
- Returns:
Log color corresponding to the given log level.
- static nocolor(string)¶
Removes color control characters from a string.
- Parameters:
string – String to remove color control characters from.
- Returns:
String without color control characters.