Package: epylog Version: 1.0.7-1 Severity: normal Tags: upstream patch
Hi! I'm running epylog with syslog-ng configured with the option options {ts_format(iso);}; for ISO-8601 timestamps which contain the full year and timezone data. These timestamps are not supported in version 1.0.7-1 of epylog. Following a patch for ISO-8601 support. I would be glad if this patch find it's way into epylog -- perhaps even in the upstram source. *** /home/olf/tmp/epylog-1.0.7-1.patch diff --git a/py/epylog/__init__.py b/py/epylog/__init__.py index ab762de..9ee7086 100644 --- a/py/epylog/__init__.py +++ b/py/epylog/__init__.py @@ -52,6 +52,7 @@ CHUNK_SIZE = 8192 GREP_LINES = 10000 QUEUE_LIMIT = 500 LOG_SPLIT_RE = re.compile(r'(.{15,15})\s+(\S+)\s+(.*)$') +LOG_SPLIT_ISO_TS_RE = re.compile(r'(\S+)\s+(\S+)\s+(.*)$') SYSLOG_NG_STRIP = re.compile(r'.*[@/]') MESSAGE_REPEATED_RE = re.compile(r'last message repeated (\S+) times') diff --git a/py/epylog/log.py b/py/epylog/log.py index f0750a8..d9e54a0 100644 --- a/py/epylog/log.py +++ b/py/epylog/log.py @@ -70,10 +70,21 @@ def mkstamp_from_syslog_datestr(datestr, monthmap): Takes a syslog date string and makes a timestamp out of it. """ try: - (m, d, t) = datestr.split()[:3] - y = str(monthmap[m]) - datestr = string.join([y, m, d, t], ' ') - tuptime = time.strptime(datestr, '%Y %b %d %H:%M:%S') + # time may be in ISO-8601 format + if datestr[10] == 'T': + # The timestamp can be given at arbitrary TZ, dependent of the + # TZ setting of the local (or remote?) syslog daemon. + # For now assume timestamps given in correct local TZ and ignore + # the specified TZ which can not be parsed with time.strptime(). + # Format of the ISO time string: + # YYYY-mm-ddTHH:MM:SS[.fraction]<timezone-spec> + # FIXME: assume timestamp in local TZ + tuptime = time.strptime(datestr[:19], '%Y-%m-%dT%H:%M:%S') + else: + (m, d, t) = datestr.split()[:3] + y = str(monthmap[m]) + datestr = string.join([y, m, d, t], ' ') + tuptime = time.strptime(datestr, '%Y %b %d %H:%M:%S') ## # Python 2.2.2 (at least) breaks with DST. # Work around. @@ -92,7 +103,11 @@ def get_stamp_sys_msg(line, monthmap): This function takes a syslog line and returns the timestamp of the event, the system where it occured, and the message. """ - mo = epylog.LOG_SPLIT_RE.match(line) + # Assume ISO-8601 timestmps when the 11'th character is 'T' + if line[10] == 'T': + mo = epylog.LOG_SPLIT_ISO_TS_RE.match(line) + else: + mo = epylog.LOG_SPLIT_RE.match(line) if not mo: raise ValueError('Unknown line format: %s' % line) time, sys, msg = mo.groups() stamp = mkstamp_from_syslog_datestr(time, monthmap) -- System Information: Debian Release: wheezy/sid APT prefers testing APT policy: (900, 'testing') Architecture: amd64 (x86_64) Kernel: Linux 3.2.0-4-amd64 (SMP w/2 CPU cores) Locale: LANG=C, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org