Module: logger - Helmigreg/ant GitHub Wiki
Technical Documentation: logger.py
Overview
This module logger.py
is part of the ANT (Automated NFT Testing) project and is responsible for logging, aggregating, and exporting the results of executed test cases.
The Logger
class allows for:
- Recording test-related events and errors.
- Accumulating statistics across all test runs.
- Writing structured logs to YAML files for further inspection and documentation.
It supports a distinction between protocol-level logs and result-level statistics and is designed to integrate closely with the ANT testing workflow.
Modulstructure
Logger
class Purpose:
Collects and manages execution results and logs during test case execution. Writes structured logs and result statistics to disk.
__init__(self)
Initializes an empty protocol and results dictionary.
- Attributes:
protocol
(dict): Stores detailed logs of individual events and errors, organized by name/tag.results
(dict): Aggregates test metrics including total tests, passed/failed, points scored, and error logs.
add_error(self, errors)
Adds error information to the results and protocol log.
- Parameters:
errors
(dict): Must contain:'list'
: A list of error messages.'tag'
: A string label under which the errors are logged.'err'
: Additional structured error data (stored in protocol).
add_event(self, events: list, name)
Appends a list of general events to the protocol log under a specified name.
- Parameters:
events
(list): List of event dictionaries to log.name
(str): Identifier under which the events are stored.
add_test_event(self, events: list, points: float, testcase)
Adds test-related event logs and updates scoring and statistics.
-
Parameters:
events
(list): List of event dictionaries. Each event is enriched with:Executing Machine
(fromtestcase.source
)- Incremented
TestNr
(relative to the total count so far)
points
(float): Points awarded for this test case.testcase
(object): Contains:name
: Identifier of the test.source
: Machine that executed the test.points
: Max points achievable for the test.
-
Effect on Results:
- Updates the
Criteria
category with scoring data for this test. - Increments counters for:
- Total tests executed
- Points reached / possible
- Successes / Failures (based on proportional scoring)
- Updates the
write(self, path_dir=None, path_res=None, path_proto=None) -> dict
Writes the proto