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:
object
scenario logger base class for the main logger and sub-loggers.
The
Logger
class 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.Logger
instance as a member variable.
- _debug_enabled¶
True
to enable log debugging.None
lets 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.Logger
instance attached with thisLogger
instance.
- enabledebug(enable_debug)¶
Debug log enabling / disabling.
- Parameters:
enable_debug –
True
for debug log enabling,False
otherwise.- Returns:
self
See the main logger and class loggers sections to learn more about debugging with
Logger
instances.
- isdebugenabled()¶
Tells whether debug logging is currently enabled for this
Logger
instance.- Returns:
True
when debug logging is enabled,False
otherwise.
- setlogcolor(color)¶
Sets or clears a log line color specialized for the logger.
- Parameters:
color – Log line color.
None
to 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.
None
when not set.
- pushindentation(indentation=' ')¶
Adds indentation for this
Logger
instance.- 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
Logger
instance.- 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
Logger
instance.- Returns:
Current indentation.
- setextraflag(extra_flag, value)¶
Sets or unsets an extra flag configuration.
- Parameters:
extra_flag – Extra flag name.
value – Extra flag configuration.
None
to unset the extra flag configuration.
- getextraflag(extra_flag)¶
Returns the extra flag configuration set (or not).
- Parameters:
extra_flag – Extra flag name.
- Returns:
True
orFalse
when the configuration is set, orNone
otherwise.
- 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_enabled
configuration (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
self
is bound with the method, even though the call was made from alogging.Logger
instance,self
remains a scenarioLogger
when 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_info
parameter.
- _torecord(level, msg, args, **kwargs)¶
After the
_log()
indirection, eventually sends the log data to the baselogging
module 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.