|
5 | 5 | It extracts and summarizes information from status lines and other log messages.
|
6 | 6 |
|
7 | 7 |
|
8 |
| -Copyright (c) 2019-2021 Software AG, Darmstadt, Germany and/or its licensors |
| 8 | +Copyright (c) 2019-2022 Software AG, Darmstadt, Germany and/or its licensors |
9 | 9 |
|
10 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
11 | 11 | file except in compliance with the License. You may obtain a copy of the License at
|
|
19 | 19 |
|
20 | 20 | """
|
21 | 21 |
|
22 |
| -__date__ = '2020-07-10' |
| 22 | +__date__ = '2022-01-07' |
23 | 23 | __version__ = '3.8.dev/'+__date__
|
24 | 24 | __author__ = "Apama community"
|
25 | 25 | __license__ = "Apache 2.0"
|
@@ -137,7 +137,7 @@ class LogLine(object):
|
137 | 137 | @ivar extraLines: unassigned, or a list of strings which are extra lines logically part of this one (typically for warn/error stacks etc)
|
138 | 138 | """
|
139 | 139 | # date level thread apama-ctrl/std cat message
|
140 |
| - LINE_REGEX = re.compile(r'(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d[.]\d\d\d) ([A-Z#]+) +\[([^\]]+)\] ([^-]*)-( <[^>]+>)? (.*)') |
| 140 | + LINE_REGEX = re.compile(r'(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d[.,]\d\d\d) ([A-Z#]+) +\[([^\]]+)\] ([^-]*)-( <[^>]+>)? (.*)') |
141 | 141 |
|
142 | 142 | __slots__ = ['line', 'lineno', 'message', 'level', '__details', 'extraLines'] # be memory-efficient
|
143 | 143 | def __init__(self, line, lineno):
|
@@ -218,9 +218,16 @@ def getDateTime(self):
|
218 | 218 | return det['datetime']
|
219 | 219 |
|
220 | 220 | try:
|
221 |
| - d = datetime.datetime.strptime(self.getDetails()['datetimestring'], '%Y-%m-%d %H:%M:%S.%f') |
| 221 | + dts = det['datetimestring'] |
| 222 | + if not dts: |
| 223 | + log.debug('Cannot find date time string in line: %s', det['datetimestring'], self.line) |
| 224 | + return None |
| 225 | + if dts[19:20] == ',': |
| 226 | + dts = dts[:19]+'.'+dts[20:] # for german locales |
| 227 | + d = datetime.datetime.strptime(dts, '%Y-%m-%d %H:%M:%S.%f') |
| 228 | + #assert d, line |
222 | 229 | except Exception as ex: # might not be a valid line
|
223 |
| - log.debug('Cannot parse date time from "%s": %s - from line: %s', self.getDetails()['datetimestring'], ex, self.line) |
| 230 | + log.debug('Cannot parse date time from "%s": %s - from line: %s', det['datetimestring'], ex, self.line) |
224 | 231 | return None
|
225 | 232 | det['datetime'] = d
|
226 | 233 | return d
|
@@ -1076,15 +1083,17 @@ def handleWarnOrError(self, file, isError, line, **extra):
|
1076 | 1083 |
|
1077 | 1084 | tracker = tracker.setdefault(normmsg, {})
|
1078 | 1085 | tracker = tracker.setdefault(self.currentpath, {})
|
| 1086 | + #assert line.getDateTime(), line |
1079 | 1087 | if not tracker:
|
1080 | 1088 | tracker['first'] = tracker['last'] = line
|
1081 | 1089 | tracker['count'] = 1
|
1082 | 1090 | tracker['samples'] = []
|
1083 | 1091 | else:
|
1084 |
| - if tracker['first'].getDateTime() > line.getDateTime(): |
1085 |
| - tracker['first'] = line |
1086 |
| - if tracker['last'].getDateTime() < line.getDateTime(): |
1087 |
| - tracker['last'] = line |
| 1092 | + if line.getDateTime(): |
| 1093 | + if tracker['first'].getDateTime() and tracker['first'].getDateTime() > line.getDateTime(): |
| 1094 | + tracker['first'] = line |
| 1095 | + if tracker['last'].getDateTime() and tracker['last'].getDateTime() < line.getDateTime(): |
| 1096 | + tracker['last'] = line |
1088 | 1097 | tracker['count'] += 1
|
1089 | 1098 |
|
1090 | 1099 | tracker['samples'].append(line)
|
|
0 commit comments