Commit
•
52bca1a
1
Parent(s):
04654e7
Only the last 300 lines
Browse files
app.py
CHANGED
@@ -17,7 +17,16 @@ def log_file_to_html_string():
|
|
17 |
|
18 |
console = Console(record=True, width=150)
|
19 |
with open(log_file, "rt") as f:
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
console.print(syntax)
|
23 |
html_content = console.export_html(inline_styles=True)
|
|
|
17 |
|
18 |
console = Console(record=True, width=150)
|
19 |
with open(log_file, "rt") as f:
|
20 |
+
# Seek to the end of the file minus 300 lines
|
21 |
+
f.seek(0, 2)
|
22 |
+
file_size = f.tell()
|
23 |
+
f.seek(max(0, file_size - 300))
|
24 |
+
# Read the last 300 lines of the file
|
25 |
+
lines = f.readlines()
|
26 |
+
|
27 |
+
# Syntax-highlight the last 300 lines of the file using the Python lexer and Monokai style
|
28 |
+
output = "".join(lines)
|
29 |
+
syntax = Syntax(output, "python", theme="monokai", word_wrap=True)
|
30 |
|
31 |
console.print(syntax)
|
32 |
html_content = console.export_html(inline_styles=True)
|