From: Thomas Jarosch Date: Tue, 8 Nov 2022 08:57:02 +0000 (+0100) Subject: Adjust SYS_LOG_PATTERN to parse single digit day number X-Git-Tag: v1.7.2~5 X-Git-Url: http://developer.intra2net.com/git/?p=pyi2ncommon;a=commitdiff_plain;h=802fdc29219e58b585ee5a6bebbfcec80e267b83 Adjust SYS_LOG_PATTERN to parse single digit day number Noticed by this failing unit test: FAIL: test_parse_messages (test_log_read.LogReadTester) Try parsing first 100 lines of messages if running on linux ---------------------------------------------------------------------- Traceback (most recent call last): File "pyi2ncommon/test/test_log_read.py", line 268, in test_parse_messages self.assertIsNotNone(data, f"Failed to parse {parser.last_unparsed_line}") AssertionError: unexpectedly None : Failed to parse Nov 7 09:24:31 storm kernel: Linux version 6.0.5-200.fc36.x86_64 (mockbuild@bkernel02.iad2.fedoraproject.org) (gcc (GCC) 12.2.1 20220819 (Red Hat 12.2.1-2), GNU ld version 2.37-36.fc36) #1 SMP PREEMPT_DYNAMIC Wed Oct 26 15:55:21 UTC 2022 --- diff --git a/src/log_read.py b/src/log_read.py index 35e50c1..ca47eb9 100644 --- a/src/log_read.py +++ b/src/log_read.py @@ -431,5 +431,5 @@ PROXY_LOG_PATTERN = \ # pattern for linux system logs (usually "messages" or "syslog" also "maillog" SYS_LOG_PATTERN = \ - r'\s*(?P\w{3} +\d{2} \d{2}:\d{2}:\d{2}) (?P\S+) ' \ + r'\s*(?P\w{3} +\d{1,2} \d{2}:\d{2}:\d{2}) (?P\S+) ' \ + r'(?P[^\[\]:]+)(?:\[(?P\d+)\])?: (?P.*)'