mirror of
https://github.com/tcsenpai/ollama.git
synced 2025-06-09 12:37:07 +00:00
Update examples/python-loganalysis/loganalysis.py
Co-authored-by: Bruce MacDonald <brucewmacdonald@gmail.com>
This commit is contained in:
parent
eced0d52ab
commit
64b7e0c218
@ -16,16 +16,12 @@ def find_errors_in_log_file():
|
|||||||
with open(log_file_path, 'r') as log_file:
|
with open(log_file_path, 'r') as log_file:
|
||||||
log_lines = log_file.readlines()
|
log_lines = log_file.readlines()
|
||||||
|
|
||||||
error_lines = []
|
error_logs = []
|
||||||
for i, line in enumerate(log_lines):
|
for i, line in enumerate(log_lines):
|
||||||
if re.search('error', line, re.IGNORECASE):
|
if "error" in line.lower():
|
||||||
error_lines.append(i)
|
start_index = max(0, i - prelines)
|
||||||
|
end_index = min(len(log_lines), i + postlines + 1)
|
||||||
error_logs = []
|
error_logs.extend(log_lines[start_index:end_index])
|
||||||
for error_line in error_lines:
|
|
||||||
start_index = max(0, error_line - prelines)
|
|
||||||
end_index = min(len(log_lines), error_line + postlines)
|
|
||||||
error_logs.extend(log_lines[start_index:end_index])
|
|
||||||
|
|
||||||
return error_logs
|
return error_logs
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user