Logging seems OK, except names
This commit is contained in:
17
iplugin.py
17
iplugin.py
@@ -1,6 +1,6 @@
|
||||
import importlib
|
||||
import inspect
|
||||
import traceback
|
||||
import logging
|
||||
|
||||
#
|
||||
# IWLA Plugin interface
|
||||
@@ -47,7 +47,9 @@ def validConfRequirements(conf_requirements, iwla, plugin_path):
|
||||
def preloadPlugins(plugins, iwla):
|
||||
cache_plugins = {}
|
||||
|
||||
print "==> Preload plugins"
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
logger.info("==> Preload plugins")
|
||||
|
||||
for (root, plugins_filenames) in plugins:
|
||||
for plugin_filename in plugins_filenames:
|
||||
@@ -61,7 +63,7 @@ def preloadPlugins(plugins, iwla):
|
||||
]
|
||||
|
||||
if not classes:
|
||||
print 'No plugin defined in %s' % (plugin_path)
|
||||
logger.warning('No plugin defined in %s' % (plugin_path))
|
||||
continue
|
||||
|
||||
plugin = classes[0](iwla)
|
||||
@@ -86,18 +88,17 @@ def preloadPlugins(plugins, iwla):
|
||||
requirement_validated = True
|
||||
break
|
||||
if not requirement_validated:
|
||||
print 'Missing requirements \'%s\' for plugin %s' % (r, plugin_path)
|
||||
logger.error('Missing requirements \'%s\' for plugin %s' % (r, plugin_path))
|
||||
break
|
||||
if requirements and not requirement_validated: continue
|
||||
|
||||
if not plugin.load():
|
||||
print 'Plugin %s load failed' % (plugin_path)
|
||||
logger.error('Plugin %s load failed' % (plugin_path))
|
||||
continue
|
||||
|
||||
print '\tRegister %s' % (plugin_path)
|
||||
logger.info('\tRegister %s' % (plugin_path))
|
||||
cache_plugins[plugin_path] = plugin
|
||||
except Exception as e:
|
||||
print 'Error loading %s => %s' % (plugin_path, e)
|
||||
traceback.print_exc()
|
||||
logger.exception('Error loading %s => %s' % (plugin_path, e))
|
||||
|
||||
return cache_plugins
|
||||
|
Reference in New Issue
Block a user