mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-03-29 02:47:23 +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 os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
import os.path
|
import os.path
|
||||||
import linecache
|
import linecache
|
||||||
import importlib.util
|
import importlib.util
|
||||||
@ -147,6 +148,7 @@ def registerRename(plugin, command=None, newName=None):
|
|||||||
|
|
||||||
def loadPluginClass(irc, module, register=None):
|
def loadPluginClass(irc, module, register=None):
|
||||||
"""Loads the plugin Class from the given module into the given Irc."""
|
"""Loads the plugin Class from the given module into the given Irc."""
|
||||||
|
loadedAt = time.time()
|
||||||
try:
|
try:
|
||||||
cb = module.Class(irc)
|
cb = module.Class(irc)
|
||||||
except TypeError as e:
|
except TypeError as e:
|
||||||
@ -179,6 +181,13 @@ def loadPluginClass(irc, module, register=None):
|
|||||||
if hasattr(cb, 'public'):
|
if hasattr(cb, 'public'):
|
||||||
public = cb.public
|
public = cb.public
|
||||||
conf.registerPlugin(plugin, register, 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), \
|
assert not irc.getCallback(plugin), \
|
||||||
'There is already a %r plugin registered.' % plugin
|
'There is already a %r plugin registered.' % plugin
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user