139 """Scan one log file and print report"""
140 tPattern = re.compile(
'|'.
join(backtrace))
141 fpeStartPattern = re.compile(
'|'.
join(fpeTracebackStart))
142 fpeContPattern = re.compile(
'|'.
join(fpeTracebackCont))
146 if args.warnings
is True:
147 categories += [
'warning']
148 if args.errors
is True:
149 categories += [
'error/fatal',
'prohibited',
'python error',
'fpe',
'backtrace']
151 igLevels = re.compile(
'|'.
join(ignorePattern))
154 cat: re.compile(
'|'.
join(regexMap[cat]))
for cat
in categories
156 resultsA = {cat:[]
for cat
in categories}
157 with open(logfile, encoding=
'utf-8')
as f:
165 if tPattern.search(line)
and not igLevels.search(line):
167 elif fpeStartPattern.search(line)
and not igLevels.search(line):
175 resultsA[
'backtrace'].
append(line)
178 if fpeStartPattern.search(line)
or fpeContPattern.search(line):
179 resultsA[
'fpe'].
append(line)
183 for cat
in categories:
184 if patterns[cat].
search(line):
185 resultsA[cat].
append(line)
188 results = {cat:[]
for cat
in categories}
189 if args.config
is None:
192 if args.showexcludestats:
193 separateIgnoreRegex = [re.compile(line)
for line
in ignorePattern]
194 ignoreDict = {line:0
for line
in ignorePattern}
197 for cat, messages
in resultsA.items():
199 if not igLevels.search(res):
201 elif args.showexcludestats:
202 for i
in range(len(separateIgnoreRegex)):
203 if separateIgnoreRegex[i].
search(res):
204 ignoreDict[ignorePattern[i]] += 1
208 found_bad_message =
False
209 for cat
in categories:
211 if args.printpatterns:
212 print(f
'check_log.py - Checking for {cat} messages with pattern: {str(patterns[cat])} in '+logfile+
'\n')
213 if len(results[cat]) > 0:
214 print(f
'Found {len(results[cat])} {cat} message(s) in {logfile}:')
215 for msg
in results[cat]:
print(msg.strip(
'\n'))
216 found_bad_message =
True
221 if ignoreDict[s] > 0:
222 print(
str(ignoreDict[s]) +
"x " + s)
225 if found_bad_message:
226 print(f
'FAILURE : problematic message found in {logfile}')
229 print(f
'No error/warning messages found in {logfile}')