Re: prelude correlator
Yoann Vandoorselaere <[email protected]> Fri, 11 Sep 2009 12:11:50 +0200
| Newsgroups | gmane.comp.security.ids.prelude.user |
|---|---|
| Message-ID | <1252663910.2393.54.camel@arwen> |
Hi Alec, Le vendredi 28 août 2009 à 17:06 +0300, Alec a écrit : > i am trying to start correlator but getting these errors: This is due to a Python 2.5 specific feature that we are using. Could you please tell me whether the attached patch help? Regards, -- Yoann Vandoorselaere | Directeur Technique/CTO | PreludeIDS Technologies Tel: +33 (0)8 70 70 21 58 Fax: +33(0)4 78 42 21 58 http://www.prelude-ids.com _______________________________________________ Prelude-user site list [email protected] http://lists.prelude-ids.org/mailman/listinfo/prelude-user
0001-Python-2.4-backward-compatibility.patch
(text/x-patch, 2.5 KB)
From f6e8e61145ce659ef6c97b15225918bf2a48f824 Mon Sep 17 00:00:00 2001 From: Yoann Vandoorselaere <[email protected]> Date: Fri, 11 Sep 2009 12:09:34 +0200 Subject: [PATCH] Python 2.4 backward compatibility The logging 'extra' keyword is only available in Python 2.5 and higher, do not use it when running an older Python version. --- PreludeCorrelator/log.py | 23 +++++++++++++++++------ 1 files changed, 17 insertions(+), 6 deletions(-) diff --git a/PreludeCorrelator/log.py b/PreludeCorrelator/log.py index ee612d1..2e54cdd 100644 --- a/PreludeCorrelator/log.py +++ b/PreludeCorrelator/log.py @@ -49,26 +49,37 @@ class Log(logging.Logger): # PreludeLog is available in recent libprelude version, we do not want to fail if it's not. pass + self._have_extra = sys.version_info > (2, 4) try: logging.config.fileConfig(conf_filename) except Exception, e: DATEFMT = "%d %b %H:%M:%S" - FORMAT="%(asctime)s (process:%(pid)d) %(levelname)s: %(message)s" + if not self._have_extra: + FORMAT="%(asctime)s %(levelname)s: %(message)s" + else: + FORMAT="%(asctime)s (process:%(pid)d) %(levelname)s: %(message)s" + logging.basicConfig(level=logging.DEBUG, format=FORMAT, datefmt=DATEFMT, stream=sys.stderr) self._logger = logging.getLogger("prelude-correlator") + def _log(self, log_func, log, extra): + if self._have_extra: + log_func(log, extra=extra) + else: + log_func(log) + def debug(self, log): - self._logger.debug(log, extra = { "pid": os.getpid() }) + self._log(self._logger.debug, log, extra = { "pid": os.getpid() }) def info(self, log): - self._logger.info(log, extra = { "pid": os.getpid() }) + self._log(self._logger.info, log, extra = { "pid": os.getpid() }) def warning(self, log): - self._logger.warning(log, extra = { "pid": os.getpid() }) + self._log(self._logger.warning, log, extra = { "pid": os.getpid() }) def error(self, log): - self._logger.error(log, extra = { "pid": os.getpid() }) + self._log(self._logger.error, log, extra = { "pid": os.getpid() }) def critical(self, log): - self._logger.critical(log, extra = { "pid": os.getpid() }) + self._log(self._logger.critical, log, extra = { "pid": os.getpid() }) -- 1.6.2.5