scenario.logformatter module

Log record formatting.

class LogFormatter

Bases: Formatter

Formats 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_DATETIME configuration, or the ExtraFlag.DATE_TIME extra flag.

Log level display:

See log levels documentation.

Log level is always displayed, unless it is disabled through the ExtraFlag.LOG_LEVEL extra flag.

Date/time display:

See log date/time documentation.

Displayed by default, unless it is disabled through the ScenarioConfig.Key.LOG_DATETIME configuration, or the ExtraFlag.DATE_TIME extra flag.

Log level display:

See log levels documentation.

Log level is always displayed, unless it is disabled through the ExtraFlag.LOG_LEVEL extra 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_CONSOLE configuration, or the ExtraFlag.COLOR extra flag.

__init__(handler)
Parameters:

handler – Attached logging.Handler.

_handler

Attached logging.Handler.

format(record)

logging method 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_flag is on or off for the given record.

Parameters:
  • extra_flag – Extra flag / logging aspect to check.

  • default – Default return value. May be set to False when required.

Returns:

True if the logging aspect described by extra_flag in on for the current record, False otherwise.

Depends on :

  1. The extra flags set in the log record,

  2. The scenario configuration,

  3. 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.