Fix incorrect auto-detection as timestamp log
TSLogParser was searching for any instance of [<number>] in a log line, which was incorrectly matching on, eg: Sep 15 18:09:46 clgrabguye21.localdomain su[160015]: ... With this change we assert that the timestamp occurs at the beginning of the line. Change-Id: I04da2f1fa661bccfd3b046dfc22e5a10f6cb37f8
This commit is contained in:
parent
1c6d22503d
commit
e73a2a35b2
|
@ -304,7 +304,8 @@ class TSLogParser(LogParser):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _read_timestamp(line):
|
def _read_timestamp(line):
|
||||||
start = line.index('[') + 1
|
# skip leading '['
|
||||||
|
start = 1
|
||||||
end = line.index(']')
|
end = line.index(']')
|
||||||
|
|
||||||
if end < start:
|
if end < start:
|
||||||
|
@ -347,6 +348,9 @@ class LogFile(object):
|
||||||
parser.parse_line(line)
|
parser.parse_line(line)
|
||||||
|
|
||||||
# It worked!
|
# It worked!
|
||||||
|
print('Detected %s as %s' %
|
||||||
|
(filename, parser.__class__.__name__),
|
||||||
|
file=sys.stderr)
|
||||||
return parser
|
return parser
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue