diff --git a/apps/predbat/web.py b/apps/predbat/web.py
index 8fee2776..bbdcd273 100644
--- a/apps/predbat/web.py
+++ b/apps/predbat/web.py
@@ -53,7 +53,7 @@ def get_attributes_html(self, entity):
continue
value = attributes[key]
if len(str(value)) > 30:
- value = str(value)[:30] + "..."
+ value = "(large data)"
text += "
{} | {} |
".format(key, value)
text += ""
return text
@@ -187,22 +187,57 @@ async def html_log(self, request):
if os.path.exists(logfile):
with open(logfile, "r") as f:
logdata = f.read()
+
+ # Decode method get arguments
+ args = request.query
+ errors = False
+ warnings = False
+ if "errors" in args:
+ errors = True
+ if "warnings" in args:
+ warnings = True
+
loglines = logdata.split("\n")
text = self.get_header("Predbat Log", refresh=10)
text += ""
+
+ if errors:
+ text += "Logfile (errors)
\n"
+ elif warnings:
+ text += "Logfile (Warnings)
\n"
+ else:
+ text += "Logfile (All)
\n"
+
+ text += '- All '
+ text += 'Warnings '
+ text += 'Errors
\n'
+
text += "\n"
total_lines = len(loglines)
count_lines = 0
lineno = total_lines - 1
- while count_lines < 1024:
+ while count_lines < 1024 and lineno >= 0:
line = loglines[lineno]
- if line:
- start_line = line[0:27]
- rest_line = line[27:]
- text += "{} | {} {} |
\n".format(lineno, start_line, rest_line)
+ line_lower = line.lower()
lineno -= 1
- count_lines += 1
+
+ start_line = line[0:27]
+ rest_line = line[27:]
+
+ if "error" in line_lower:
+ text += "{} | {} {} |
\n".format(lineno, start_line, rest_line)
+ count_lines += 1
+ continue
+ elif (not errors) and ("warn" in line_lower):
+ text += "{} | {} {} |
\n".format(lineno, start_line, rest_line)
+ count_lines += 1
+ continue
+
+ if line and (not errors) and (not warnings):
+ text += "{} | {} {} |
\n".format(lineno, start_line, rest_line)
+ count_lines += 1
+
text += "
"
text += "