summaryrefslogtreecommitdiffstats
path: root/LogActio
diff options
context:
space:
mode:
authorDavid Sommerseth <davids@redhat.com>2012-09-16 15:15:04 +0200
committerDavid Sommerseth <davids@redhat.com>2012-09-16 15:15:04 +0200
commit2fd3b0c451ce8e3d007029520bf2e4f48afd5d40 (patch)
tree7272b59857ca9ed2b0efc5f94f2ddbed5d43ff96 /LogActio
parenta6893e56c1926c1365b5c217972b76c5491d51ae (diff)
downloadlogactio-2fd3b0c451ce8e3d007029520bf2e4f48afd5d40.tar.gz
logactio-2fd3b0c451ce8e3d007029520bf2e4f48afd5d40.tar.xz
logactio-2fd3b0c451ce8e3d007029520bf2e4f48afd5d40.zip
Implement support for external reporter modules
The [Reporter:*] definitions can now take the 'module' variable, which is the name of the reporter module, located in LogActio/Reporters/ Signed-off-by: David Sommerseth <davids@redhat.com>
Diffstat (limited to 'LogActio')
-rw-r--r--LogActio/__init__.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/LogActio/__init__.py b/LogActio/__init__.py
index 39bce93..e65f12a 100644
--- a/LogActio/__init__.py
+++ b/LogActio/__init__.py
@@ -110,6 +110,7 @@ class LogActio(object):
raise e
self.__watchthreads = []
+ self.__ext_modules = {}
self.__shutdown = False
self.__daemon = daemon
self.__pidfp = None
@@ -183,10 +184,22 @@ class LogActio(object):
for k,v in self.__cfg.items(entry):
repcfg[k] = v
+ if repcfg.has_key("module"):
+ # import this reporter module, but only if it is unkown
+ extmodule = repcfg["module"]
+ if not self.__ext_modules.has_key(extmodule):
+ self.__ext_modules[extmodule] = __import__("LogActio.Reporters.%s" % extmodule,
+ fromlist="LogActio.Reporters")
+ else:
+ extmodule = None
+
if repname == "Default":
__reporters[repname] = DefaultReporter(repcfg. self.__log)
+ elif extmodule is not None:
+ __reporters[repname] = self.__ext_modules[extmodule].InitReporter(repcfg, self.__log)
else:
- raise Exception("The module loader for reporters have not been implemented (%s)" % repname)
+ raise Exception("Dazed and confused - this shouldn't happen (repname: %s)" % repname)
+
del repcfg
self.__log(2, "Configured reporter %s: %s" % (repname, __reporters[repname].GetName()))
@@ -214,7 +227,7 @@ class LogActio(object):
except ConfigParser.NoOptionError:
polltime = None
- # Extract the reporter to use for this log file
+ # Extract the default reporter to use for this log file
try:
repname = self.__cfg.get(entry, "reporter")
reporter = __reporters[repname]