New log-analysis checker LastLineContains
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
import re
|
||||
import os
|
||||
import logging
|
||||
from collections import deque
|
||||
|
||||
class Default:
|
||||
def run(file, opt=None):
|
||||
@@ -44,6 +45,14 @@ class ContainsString:
|
||||
return True, ""
|
||||
return False, f"could not find '{needle}' in logs"
|
||||
|
||||
class LastLineContains:
|
||||
def run(file, string):
|
||||
with open(file, "r") as f:
|
||||
last_line = deque(f, maxlen=1).pop()
|
||||
success = string in last_line
|
||||
log = "" if success else f"could not find '{string}' in last line"
|
||||
return success, log
|
||||
|
||||
class RetxCheck():
|
||||
def _parseList(s):
|
||||
if not s:
|
||||
|
||||
Reference in New Issue
Block a user