Hello. I was having trouble reading the logs on Nginx Free Fireware. I ran it with the code below. Could you please fix this issue in the next update? Thank you very much. I wish you continued success.

`def get_safe_logs(self, get):
try:
import cgi
import json
import sys
import os
import time
import html
pythonV = sys.version_info[0]
# Select log path
if 'drop_ip' in get:
path = '/www/server/free_waf/drop_ip.log'
num = 14
else:
path = f"/www/wwwlogs/free_waf_log/{get.siteName}_{get.toDate}.log"
num = 10
if not os.path.exists(path):
print(f"Log file not found: {path}")
return []
p = int(get.p) if hasattr(get, 'p') else 1
start_line = (p - 1) * num
data = []
try:
with open(path, 'rb') as fp:
# Check file size
fp.seek(0, 2)
file_size = fp.tell()
if file_size == 0:
print("Log file is empty")
return []
fp.seek(0) # rewind
# Read file line by line
line_count = 0
for line_bytes in fp:
try:
line = (
line_bytes.decode('utf-8', errors='ignore').strip()
if pythonV == 3 else line_bytes.strip()
)
if not line:
continue
tmp_data = json.loads(line)
if start_line <= line_count < start_line + num:
# Escape HTML fields
for i in range(len(tmp_data)):
if i == 7: # args field
tmp_data[i] = (
str(tmp_data[i])
.replace('&', '&')
.replace('<', '<')
.replace('>', '>')
)
else:
tmp_data[i] = (
html.escape(str(tmp_data[i]), quote=True)
if pythonV == 3 else cgi.escape(str(tmp_data[i]), True)
)
data.append(tmp_data)
line_count += 1
if len(data) >= num: # enough logs collected
break
except json.JSONDecodeError as e:
print(f"JSON parse error at line {line_count}: {e}")
print(f"Invalid line: {line[:100]}...")
continue
except Exception as e:
print(f"Line processing error {line_count}: {e}")
continue
except Exception as e:
print(f"File read error: {e}")
return []
# Drop IP processing
if 'drop_ip' in get:
try:
drop_iplist = self.get_waf_drop_ip(None)
stime = time.time()
seen_ips = set()
for i in range(len(data)):
try:
if (
(float(stime) - float(data[i][0])) < float(data[i][4])
and data[i][1] not in seen_ips
):
seen_ips.add(data[i][1])
data[i].append(data[i][1] in drop_iplist)
else:
data[i].append(False)
except (IndexError, ValueError) as e:
print(f"Drop IP processing error: {e}")
data[i].append(False)
except Exception as e:
print(f"Drop IP check error: {e}")
except Exception as e:
print(f"General error: {e}")
return []
print(f"Total {len(data)} log records loaded")
return data
`