From 9c1abc4b75b941f434d6a120bd1c8fc4f1031c30 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Tue, 16 Dec 2014 13:20:59 +0100 Subject: [PATCH 1/1] ignore badly formatted log lines --- munin/nominatim_query_speed_querylog | 5 ++--- munin/nominatim_requests_querylog | 5 ++--- utils/cron_ipanalyse.py | 5 ++++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/munin/nominatim_query_speed_querylog b/munin/nominatim_query_speed_querylog index d663faf1..4bbeac68 100755 --- a/munin/nominatim_query_speed_querylog +++ b/munin/nominatim_query_speed_querylog @@ -128,9 +128,8 @@ class LogFile: def loglines(self): for l in self.fd: e = ENTRY_REGEX.match(l) - if e is None: - raise ValueError("Invalid log line:", l) - yield e.groupdict() + if e is not None: + yield e.groupdict() if __name__ == '__main__': diff --git a/munin/nominatim_requests_querylog b/munin/nominatim_requests_querylog index 8538a95c..aa41a4de 100755 --- a/munin/nominatim_requests_querylog +++ b/munin/nominatim_requests_querylog @@ -121,9 +121,8 @@ class LogFile: def loglines(self): for l in self.fd: e = ENTRY_REGEX.match(l) - if e is None: - raise ValueError("Invalid log line:", l) - yield e.groupdict() + if e is not None: + yield e.groupdict() if __name__ == '__main__': diff --git a/utils/cron_ipanalyse.py b/utils/cron_ipanalyse.py index 262090a4..18582667 100755 --- a/utils/cron_ipanalyse.py +++ b/utils/cron_ipanalyse.py @@ -186,7 +186,10 @@ class LogFile: def loglines(self): for l in self.fd: - yield LogEntry(l) + try: + yield LogEntry(l) + except ValueError: + pass # ignore invalid lines class BlockList: -- 2.39.5