diff --git a/cognee/shared/utils.py b/cognee/shared/utils.py index e57decde1..affd92c87 100644 --- a/cognee/shared/utils.py +++ b/cognee/shared/utils.py @@ -468,16 +468,20 @@ def graph_to_tuple(graph): def setup_logging(log_level=logging.INFO): - """This method sets up the logging configuration.""" + """Sets up the logging configuration.""" formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s\n") + stream_handler = logging.StreamHandler(sys.stdout) stream_handler.setFormatter(formatter) stream_handler.setLevel(log_level) - logging.basicConfig( - level=log_level, - handlers=[stream_handler], - ) + root_logger = logging.getLogger() + + if root_logger.hasHandlers(): + root_logger.handlers.clear() + + root_logger.addHandler(stream_handler) + root_logger.setLevel(log_level) # ---------------- Example Usage ---------------- diff --git a/examples/python/dynamic_steps_example.py b/examples/python/dynamic_steps_example.py index 11596a5e2..4422dd39d 100644 --- a/examples/python/dynamic_steps_example.py +++ b/examples/python/dynamic_steps_example.py @@ -192,7 +192,7 @@ async def main(enable_steps): if __name__ == "__main__": - setup_logging(logging.INFO) + setup_logging(logging.ERROR) rebuild_kg = True retrieve = True