Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve plugin loading logging #527

Merged
merged 1 commit into from
May 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions galicaster/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

logger = context.get_logger()
loaded = []
prefixes = {'galicaster.plugins.': 'Internal',
'galicaster_plugin_': 'External'}


def init():
global loaded
Expand All @@ -24,17 +27,24 @@ def init():
list_plugins = conf.get_section('plugins')
for plugin, v in list_plugins.iteritems():
if v.lower() == 'true':
for prefix in ['galicaster.plugins.', 'galicaster_plugin_']:
for prefix in prefixes:
plugin_type = prefixes[prefix]
try:
name = prefix + plugin
__import__(name)
sys.modules[name].init()
logger.info('Plugin {0} started'.format(plugin))
logger.info('{} plugin {} started'.format(plugin_type,
plugin))
loaded.append(name)
break
except Exception as exc:
logger.error('Exception thrown when starting plugin {}: {}'.format(plugin, exc))
except Exception as e:
if e.message == 'No module named {}'.format(plugin):
logger.warning('{} plugin {} not found'
.format(plugin_type, plugin))
else:
logger.error('Exception thrown starting plugin {}:'
.format(plugin), exc_info=True)
else:
logger.error('Error starting plugin {}: {}'.format(plugin, exc))
logger.error('Error starting plugin {}'.format(plugin))
else:
logger.info('Plugin {0} not enabled in conf'.format(plugin))