mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 11:42:52 +01:00
Log loading times for each plugin
It makes it easier to debug long startup times.
This commit is contained in:
parent
fd873fa0a5
commit
6b1460e160
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user