Skip to content

Logger

GlobalLogger

A global logger to store all the requests made by the client.

log_request(log) classmethod

Add a log entry to the logs list. Args: log: A dictionary containing the log entry.

get_logs() classmethod

Get all the logs stored in the logger. Returns: A list of log entries.

Examples:

>>> from reqflow.utils.logger import GlobalLogger
>>>
>>> logs = GlobalLogger.get_logs()
>>> print(logs)
>>> [{'function': 'test_function', 'request': {'method': 'GET', 'url': 'https://some_url.com', 'params': {}, 'headers': {}, 'cookies': {}, 'json': None, 'data': None, 'redirect': 'auto', 'files': None, 'timeout': None}, 'response': {'status_code': 200, 'headers': {'Content-Type': 'application/json'}, 'content': b'{"key": "value"}', 'time': 0.123}}]

clear_logs() classmethod

Clear all the logs stored in the logger.

Examples:

>>> from reqflow.utils.logger import GlobalLogger
>>>
>>> GlobalLogger.clear_logs()

generate_html_report(file_path='test_report.html', report_title='Test Report') classmethod

Generate an HTML report from the logs across all client instances. Args: file_path: (str) The path/name to save the HTML report. report_title: (str) The name of the report.

Examples:

>>> from reqflow.utils.logger import GlobalLogger
>>>
>>> GlobalLogger.generate_html_report(file_path="test_report.html", report_title="Aggregated Requests")

generate_json_report(file_path='test_report.json') classmethod

Generate a JSON report from the logs across all client instances. Args: file_path: (str) The path/name to save the HTML report.

Examples:

>>> from reqflow.utils.logger import GlobalLogger
>>>
>>> GlobalLogger.generate_json_report(file_path="test_report.json")