scenario.logger module¶
Logger class definition.
- _main_loggers¶
Number of main loggers already created.
Constitutes a guard against the creation of several main loggers, i.e. loggers without a log class.
- class Logger¶
Bases:
objectscenario logger base class for the main logger and sub-loggers.
The
Loggerclass enables you to make your log lines be controlled by a log class. This will make the log lines be prefixed with the given log class, and give you the opportunity to activate or deactivate the corresponding debug log lines programmatically (seeenabledebug()) or by configuration (seeScenarioConfig.debugclasses()).- __init__(log_class)¶
- Parameters:
log_class –
Log class.
Empty string for the main logger (for the main logger only!).
See also
- log_class¶
Log class.
- _logger¶
logging.Loggerinstance as a member variable.
- _debug_enabled¶
Trueto enable log debugging.Nonelets the configuration tells whether debug log lines should be displayed for this logger.
- _log_color¶
Optional log color configuration.
- _indentation¶
Logger indentation.
- _extra_flags¶
Extra flags configurations.
- property logging_instance¶
Provides the reference of the
logging.Loggerinstance attached with thisLoggerinstance.
- enabledebug(enable_debug)¶
Debug log enabling / disabling.
- Parameters:
enable_debug –
Truefor debug log enabling,Falseotherwise.- Returns:
self
See the main logger and class loggers sections to learn more about debugging with
Loggerinstances.
- isdebugenabled()¶
Tells whether debug logging is currently enabled for this
Loggerinstance.- Returns:
Truewhen debug logging is enabled,Falseotherwise.
- setlogcolor(color)¶
Sets or clears a log line color specialized for the logger.
- Parameters:
color – Log line color.
Noneto reset to default.
Log class colorization offers the possibilty to differenciate log lines betwwen different loggers running at the same time, each one having its own color. See the log class colorization section for detailed information.
- getlogcolor()¶
Returns the specialized log line color for this logger, if any.
- Returns:
Log line color.
Nonewhen not set.
- pushindentation(indentation=' ')¶
Adds indentation for this
Loggerinstance.- Parameters:
indentation – Optional indentation pattern.
See the dedicated sections to learn more about the differences between calling this method on the main logger on the one hand, and on a class logger on the other hand.
- popindentation(indentation=' ')¶
Removes indentation for the
Loggerinstance.- Parameters:
indentation – Optional indentation pattern. Must be the same as the indentation pattern passed on with the matching
pushindentation()call on a LIFO basis (Last-In First-Out).
- getindentation()¶
Returns the current indentation attached with this
Loggerinstance.- Returns:
Current indentation.
- setextraflag(extra_flag, value)¶
Sets or unsets an extra flag configuration.
- Parameters:
extra_flag – Extra flag name.
value – Extra flag configuration.
Noneto unset the extra flag configuration.
- getextraflag(extra_flag)¶
Returns the extra flag configuration set (or not).
- Parameters:
extra_flag – Extra flag name.
- Returns:
TrueorFalsewhen the configuration is set, orNoneotherwise.
- error(msg, *args, **kwargs)¶
Logs an error message with this logger.
- warning(msg, *args, **kwargs)¶
Logs a warning message with this logger.
- info(msg, *args, **kwargs)¶
Logs an informational message with this logger.
- debug(msg, *args, **kwargs)¶
Logs a debug message with this logger.
The processing of the message depends on the
_debug_enabledconfiguration (seeenabledebug()).
- log(level, msg, *args, **kwargs)¶
Logs a message with a configurable severity.
- _log(level, msg, args, **kwargs)¶
logging.Logger._log()method indirection.- Parameters:
self – In as much as
selfis bound with the method, even though the call was made from alogging.Loggerinstance,selfremains a scenarioLoggerwhen we arrive here.level – Log level.
msg – Log message.
args – Other positional arguments as a tuple.
kwargs – Named parameter arguments.
Handles appropriately the optional
exc_infoparameter.
- _torecord(level, msg, args, **kwargs)¶
After the
_log()indirection, eventually sends the log data to the baseloggingmodule to create a log record.- Parameters:
level – Log level.
msg – Log message.
args – Other positional arguments as a tuple.
kwargs – Named parameter arguments.
- longtext(max_lines)¶
Builds the long text extra option in order to display the log message as several lines.
- Parameters:
max_lines – Maximum number of lines.
- Returns:
long text extra option.
See the long text logging section for more details.
- _loglongtext(level, msg, args, max_lines, **kwargs)¶
Logs the beginning of a long text on multiple lines.
- Parameters:
level – Log level.
msg – Log message.
args – Other positional arguments as a tuple.
max_lines – Maximum number of lines to display. All lines when set to
None.kwargs – Named parameter arguments.