Fixed some debugging that actually caused a bug.

This commit is contained in:
Storm Dragon 2025-04-04 02:23:16 -04:00
parent cd76760d9f
commit 6463e03a1a

View File

@ -613,11 +613,16 @@ def loadUserSettings(script=None, inputEvent=None, skipReloadMessage=False):
# Make plugin loading more robust by handling potential exceptions
try:
activePlugins = list(_settingsManager.getSetting('activePlugins'))
logger.info(f"CTHULHU: Loading active plugins: {activePlugins}")
# Use debug module for logging instead of the logger module
debug.printMessage(debug.LEVEL_INFO, f"CTHULHU: Loading active plugins: {activePlugins}", True)
# Setup a timeout for plugin activation to prevent hanging
import threading
import time
import logging
# Setup proper logging
log = logging.getLogger("cthulhu.plugins")
activation_completed = [False]
@ -626,9 +631,9 @@ def loadUserSettings(script=None, inputEvent=None, skipReloadMessage=False):
cthulhuApp.getPluginSystemManager().setActivePlugins(activePlugins)
activation_completed[0] = True
except Exception as e:
logger.error(f"CTHULHU: Error activating plugins: {e}")
debug.printMessage(debug.LEVEL_WARNING, f"CTHULHU: Error activating plugins: {e}", True)
import traceback
logger.error(traceback.format_exc())
debug.printMessage(debug.LEVEL_WARNING, traceback.format_exc(), True)
plugin_thread = threading.Thread(target=activate_plugins_with_timeout)
plugin_thread.daemon = True # Make thread daemonic so it doesn't block program exit
@ -638,11 +643,11 @@ def loadUserSettings(script=None, inputEvent=None, skipReloadMessage=False):
plugin_thread.join(30)
if not activation_completed[0]:
logger.error("CTHULHU: Plugin activation timed out - continuing without all plugins")
debug.printMessage(debug.LEVEL_WARNING, "CTHULHU: Plugin activation timed out - continuing without all plugins", True)
except Exception as e:
logger.error(f"CTHULHU: Error setting up plugin activation: {e}")
debug.printMessage(debug.LEVEL_WARNING, f"CTHULHU: Error setting up plugin activation: {e}", True)
import traceback
logger.error(traceback.format_exc())
debug.printMessage(debug.LEVEL_WARNING, traceback.format_exc(), True)
_scriptManager.activate()
_eventManager.activate()