From 6b1460e1601e9aa33705593ee44b87234d9043cb Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sun, 11 Apr 2021 16:35:39 +0200 Subject: [PATCH] Log loading times for each plugin It makes it easier to debug long startup times. --- src/plugin.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/plugin.py b/src/plugin.py index 3f9723709..f105fcfdf 100644 --- a/src/plugin.py +++ b/src/plugin.py @@ -30,6 +30,7 @@ import os import re import sys +import time import os.path import linecache import importlib.util @@ -147,6 +148,7 @@ def registerRename(plugin, command=None, newName=None): def loadPluginClass(irc, module, register=None): """Loads the plugin Class from the given module into the given Irc.""" + loadedAt = time.time() try: cb = module.Class(irc) except TypeError as e: @@ -179,6 +181,13 @@ def loadPluginClass(irc, module, register=None): if hasattr(cb, 'public'): public = cb.public conf.registerPlugin(plugin, register, public) + + loadTime = time.time() - loadedAt + if loadTime > 1: + log.warning("Loaded plugin %s in %s ms.", plugin, int(loadTime*1000)) + else: + log.debug("Loaded plugin %s in %s ms", plugin, int(loadTime*1000)) + assert not irc.getCallback(plugin), \ 'There is already a %r plugin registered.' % plugin try: