prelude-correlator/master: Make use of the command line specified configuration file, if any
[email protected] Thu, 9 Jul 2009 17:57:28 +0200 (CEST)
| Newsgroups | gmane.comp.security.ids.prelude.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit 68a5806ff499eec4e4a6816135b75f7ffbc66d0f Author: Yoann Vandoorselaere <[email protected]> Date: Thu Jul 9 16:55:32 2009 +0200 Make use of the command line specified configuration file, if any ======================================== PreludeCorrelator/log.py | 5 ++--- PreludeCorrelator/main.py | 12 +++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) ======================================== diff --git a/PreludeCorrelator/log.py b/PreludeCorrelator/log.py index 168212f..ee612d1 100644 --- a/PreludeCorrelator/log.py +++ b/PreludeCorrelator/log.py @@ -18,7 +18,6 @@ # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. import PreludeEasy -from PreludeCorrelator import require import logging, logging.config, logging.handlers, sys, os class Log(logging.Logger): @@ -43,7 +42,7 @@ class Log(logging.Logger): else: self.warnings(("[unknown:%d] " % level) + log) - def __init__(self): + def __init__(self, conf_filename): try: PreludeEasy.PreludeLog.SetCallback(self.__log_callback) except: @@ -51,7 +50,7 @@ class Log(logging.Logger): pass try: - logging.config.fileConfig(require.get_config_filename(None, "prelude-correlator.conf")) + logging.config.fileConfig(conf_filename) except Exception, e: DATEFMT = "%d %b %H:%M:%S" FORMAT="%(asctime)s (process:%(pid)d) %(levelname)s: %(message)s" diff --git a/PreludeCorrelator/main.py b/PreludeCorrelator/main.py index 8ad0932..0cf27ba 100644 --- a/PreludeCorrelator/main.py +++ b/PreludeCorrelator/main.py @@ -31,10 +31,10 @@ LIBPRELUDE_REQUIRED_VERSION = "0.9.23" class Env: - def __init__(self): - self.logger = log.Log() + def __init__(self, conf_filename): + self.logger = log.Log(conf_filename) - self.config = config.Config(require.get_config_filename(None, "prelude-correlator.conf")) + self.config = config.Config(conf_filename) self.pluginmanager = pluginmanager.PluginManager(self) self.logger.info("%d plugin have been loaded." % (self.pluginmanager.getPluginCount())) @@ -121,10 +121,10 @@ def main(): if not CheckVersion(LIBPRELUDE_REQUIRED_VERSION): raise Exception, ("Libprelude version '%s' is required" % LIBPRELUDE_REQUIRED_VERSION) - env = Env() + config_filename = require.get_config_filename(None, "prelude-correlator.conf") parser = OptionParser(usage="%prog", version="%prog " + VERSION) - parser.add_option("-c", "--config", action="store", dest="config", type="string", help="Configuration file to use", metavar="FILE") + parser.add_option("-c", "--config", action="store", dest="config", type="string", help="Configuration file to use", metavar="FILE", default=config_filename) parser.add_option("", "--dry-run", action="store_true", dest="dry_run", help="No report to the specified Manager will occur", default=False) parser.add_option("-d", "--daemon", action="store_true", dest="daemon", help="Run in daemon mode") parser.add_option("-P", "--pidfile", action="store", dest="pidfile", type="string", help="Write Prelude Correlator PID to specified file", metavar="FILE") @@ -133,6 +133,8 @@ def main(): parser.add_option("--debug", action="store", dest="debug", type="int", help="Enable debug ouptut (optional debug level argument)", metavar="LEVEL") (options, args) = parser.parse_args() + env = Env(options.config) + ifd = None if options.print_input: if options.print_input == "-": _______________________________________________ Prelude-cvslog site list [email protected] http://lists.prelude-ids.org/mailman/listinfo/prelude-cvslog