From 2c11a206425a2609852850bc4b3412ee330b9e5d Mon Sep 17 00:00:00 2001 From: Abodi Massarwa Date: Thu, 8 Aug 2024 21:47:59 +0300 Subject: [PATCH] =?UTF-8?q?hopefully=20final=20commit=20:-)=20=F0=9F=99=8F?= =?UTF-8?q?=F0=9F=8F=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../heterogeneous_matroid_constraints_algorithms.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fairpyx/algorithms/heterogeneous_matroid_constraints_algorithms.py b/fairpyx/algorithms/heterogeneous_matroid_constraints_algorithms.py index 1c790a8..6323e1a 100644 --- a/fairpyx/algorithms/heterogeneous_matroid_constraints_algorithms.py +++ b/fairpyx/algorithms/heterogeneous_matroid_constraints_algorithms.py @@ -21,6 +21,8 @@ import base64 logger = logging.getLogger(__name__) +# Create a string stream to capture logs +log_stream = io.StringIO() def per_category_round_robin(alloc: AllocationBuilder, item_categories: dict[str,list], agent_category_capacities: dict[str,dict[str,int]], initial_agent_order: list,callback:callable=None): @@ -1267,6 +1269,16 @@ def helper_generate_bipartite_graph_base64(graph,iteration:int,category:str): return base64.b64encode(img_bytes.read()).decode('utf-8') +def helper_configure_logger(): + stream_handler = logging.StreamHandler(log_stream) + formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') + logger.addHandler(stream_handler) + stream_handler.setFormatter(formatter) + logger.setLevel(logging.DEBUG) + +def helper_get_logs(): + return log_stream.getvalue() + if __name__ == "__main__": import doctest, sys #print("\n", doctest.testmod(), "\n")