logger - Logging Facility
DTS logger module.
The module provides several additional features:
The storage of DTS execution stages,
Logging to console, a human-readable log artifact and a machine-readable log artifact,
Optional log artifacts for specific stages.
- class ArtifactHandler
Bases:
NamedTupleA logger handler with an associated artifact.
- artifact: Artifact
Alias for field number 0
- handler: StreamHandler
Alias for field number 1
- static __new__(_cls, artifact: Artifact, handler: StreamHandler)
Create new instance of ArtifactHandler(artifact, handler)
- class DTSLogger
Bases:
LoggerThe DTS logger class.
The class extends the
Loggerclass to add the DTS execution stage information to log records. The stage is common to all loggers, so it’s stored in a class variable.Any time we switch to a new stage, we have the ability to log to an additional log artifact along with a supplementary log artifact with machine-readable format. These two log artifacts are used until a new stage switch occurs. This is useful mainly for logging per test suite.
- __init__(*args: Any, **kwargs: Any) None
Extend the constructor with extra artifact handlers.
- add_dts_root_logger_handlers(verbose: bool) None
Add logger handlers to the DTS root logger.
This method should be called only on the DTS root logger. The log records from child loggers will propagate to these handlers.
Three handlers are added:
A console handler,
An artifact handler,
A supplementary artifact handler with machine-readable logs containing more debug information.
All log messages will be logged to artifacts. The log level of the console handler is configurable with verbose.
- Parameters:
verbose (bool) – If
True, log all messages to the console. IfFalse, log to console with thelogging.INFOlevel.
- set_stage(stage: str) None
Set the DTS execution stage.
- Parameters:
stage (str) – The DTS stage to set.
- set_custom_log_file(log_file_name: str | None) None
Set a custom log file.
Add artifact handlers to the instance if the log artifact file name is provided. Otherwise, stop logging to any custom log file.
The artifact handlers log all messages. One is a regular human-readable log artifact and the other one is a machine-readable log artifact with extra debug information.
- Parameters:
log_file_name (str | None) – An optional name of the log artifact file to use. This should be without suffix (which will be appended).
- get_dts_logger(name: str | None = None) DTSLogger
Return a DTS logger instance identified by name.
- Parameters:
name (str | None) – If
None, return the DTS root logger. If specified, return a child of the DTS root logger.- Returns:
The DTS root logger or a child logger identified by name.
- Return type: