Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

Update examples/python-loganalysis/loganalysis.py

Matt Williams64b7e0c218d8
diff --git a/examples/python-loganalysis/loganalysis.py b/examples/python-loganalysis/loganalysis.py
index e93850655..2b7ddd489 100644
--- a/examples/python-loganalysis/loganalysis.py
+++ b/examples/python-loganalysis/loganalysis.py
@@ -16,16 +16,12 @@ def find_errors_in_log_file():
with open(log_file_path, 'r') as log_file:
log_lines = log_file.readlines()
- error_lines = []
- for i, line in enumerate(log_lines):
- if re.search('error', line, re.IGNORECASE):
- error_lines.append(i)
-
- error_logs = []
- 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])
+error_logs = []
+ for i, line in enumerate(log_lines):
+ if "error" in line.lower():
+ start_index = max(0, i - prelines)
+ end_index = min(len(log_lines), i + postlines + 1)
+ error_logs.extend(log_lines[start_index:end_index])
return error_logs