From dd2dcf3adeaf2228551ab21f21bfc388cb300ac6 Mon Sep 17 00:00:00 2001 From: Aziz Berkay Yesilyurt Date: Fri, 11 Oct 2024 16:45:22 +0300 Subject: [PATCH] fix exception logging --- syftbox/client/client.py | 4 +--- syftbox/client/plugins/sync.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/syftbox/client/client.py b/syftbox/client/client.py index d7cf8885..9683346a 100644 --- a/syftbox/client/client.py +++ b/syftbox/client/client.py @@ -5,7 +5,6 @@ import os import sys import time -import traceback import types from dataclasses import dataclass from datetime import datetime @@ -170,8 +169,7 @@ def run_plugin(plugin_name, *args, **kwargs): module = app.loaded_plugins[plugin_name].module module.run(app.shared_state, *args, **kwargs) except Exception as e: - traceback.logger.info_exc() - logger.info("error", e) + logger.exception(e) def start_plugin(app: CustomFastAPI, plugin_name: str): diff --git a/syftbox/client/plugins/sync.py b/syftbox/client/plugins/sync.py index 584826db..4a41ce1a 100644 --- a/syftbox/client/plugins/sync.py +++ b/syftbox/client/plugins/sync.py @@ -1,5 +1,4 @@ import os -import traceback from collections import defaultdict from datetime import datetime from threading import Event @@ -652,8 +651,8 @@ def do_sync(shared_state): try: create_datasites(shared_state.client_config) except Exception as e: - traceback.logger.info_exc() - logger.info("failed to get_datasites", e) + logger.error("failed to get_datasites", e) + logger.exception(e) try: if SYNC_UP_ENABLED: @@ -661,8 +660,8 @@ def do_sync(shared_state): else: logger.info("❌ Sync Up Disabled") except Exception as e: - traceback.logger.info_exc() - logger.info("failed to sync up", e) + logger.error("failed to sync up", e) + logger.exception(e) try: if SYNC_DOWN_ENABLED: @@ -670,15 +669,16 @@ def do_sync(shared_state): else: logger.info("❌ Sync Down Disabled") except Exception as e: - traceback.logger.info_exc() - logger.info("failed to sync down", e) + logger.error("failed to sync down", e) + logger.exception(e) if num_changes == 0: if event_length: logger.info(f"✅ Synced {event_length} File Events") else: logger.info("✅ Synced due to Timer") except Exception as e: - logger.info("Failed to run plugin", e) + logger.error("Failed to run plugin") + logger.exception(e) FLUSH_SYNC_TIMEOUT = 0.5