ircbot: add some debug logging in plugin (un)load

This commit is contained in:
Brian S. Stephan 2016-01-17 09:21:29 -06:00
parent 4c949ee6f3
commit 676f479d52
1 changed files with 23 additions and 2 deletions

View File

@ -591,13 +591,19 @@ class IRCBot(irc.client.SimpleIRCClient):
The general assumption here is that a plugin's init loads its hooks and handlers.
"""
log.debug("trying to load %s", plugin_path)
log.debug("trying to load plugin %s", plugin_path)
dest = None
if feedback:
dest = ircbotlib.reply_destination_for_event(event)
# loop over the sys.modules entries, for debugging
log.debug("loaded modules:")
for module_name, module in sys.modules.items():
log.debug(" %s", module_name)
for path, plugin in self.plugins:
log.debug("looping already loaded plugin: %s %s", plugin, path)
if plugin_path == path:
if feedback:
self.privmsg(dest, "Plugin '{0:s}' is already loaded.".format(plugin_path))
@ -629,6 +635,11 @@ class IRCBot(irc.client.SimpleIRCClient):
if feedback:
self.privmsg(dest, "Plugin '{0:s}' could not be loaded: {1:s}".format(plugin_path, str(e)))
# loop over the sys.modules entries, for debugging
log.debug("new list of loaded modules:")
for module_name, module in sys.modules.items():
log.debug(" %s", module_name)
def handle_unload(self, connection, event, match):
"""Handle IRC requests to unload a plugin."""
@ -642,10 +653,15 @@ class IRCBot(irc.client.SimpleIRCClient):
def _unload_plugin(self, connection, event, plugin_path):
"""Attempt to unload and del a module if it's loaded."""
log.debug("trying to unload %s", plugin_path)
log.debug("trying to unload plugin %s", plugin_path)
dest = ircbotlib.reply_destination_for_event(event)
# loop over the sys.modules entries, for debugging
log.debug("loaded modules:")
for module_name, module in sys.modules.items():
log.debug(" %s", module_name)
unloaded = False
for path, plugin in self.plugins:
if plugin_path == path:
@ -660,6 +676,11 @@ class IRCBot(irc.client.SimpleIRCClient):
if not unloaded:
self.privmsg(dest, "Plugin '{0:s}' is not loaded.".format(plugin_path))
# loop over the sys.modules entries, for debugging
log.debug("new list of loaded modules:")
for module_name, module in sys.modules.items():
log.debug(" %s", module_name)
def privmsg(self, target, text):
"""Send a PRIVMSG command.