Development
This commit is contained in:
parent
b8f1e5f980
commit
4a24c71d87
1 changed files with 4 additions and 2 deletions
|
|
@ -465,6 +465,7 @@ DDNS_LOG_MAX = 50
|
||||||
def _ddns_log_tail():
|
def _ddns_log_tail():
|
||||||
log_path = f'{CONFIGS_DIR}/ddns.log'
|
log_path = f'{CONFIGS_DIR}/ddns.log'
|
||||||
try:
|
try:
|
||||||
|
size_kb = os.path.getsize(log_path) / 1024
|
||||||
with open(log_path) as f:
|
with open(log_path) as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
if not lines:
|
if not lines:
|
||||||
|
|
@ -473,10 +474,11 @@ def _ddns_log_tail():
|
||||||
tail = lines[-DDNS_LOG_MAX:]
|
tail = lines[-DDNS_LOG_MAX:]
|
||||||
shown = len(tail)
|
shown = len(tail)
|
||||||
hidden = total - shown
|
hidden = total - shown
|
||||||
|
size_str = f'{size_kb:.1f}KB'
|
||||||
if hidden > 0:
|
if hidden > 0:
|
||||||
summary = f'Showing last {shown} lines ({hidden} lines not shown)'
|
summary = f'Log file size: {size_str}. Showing last {shown} lines ({hidden} lines not shown).'
|
||||||
else:
|
else:
|
||||||
summary = f'Showing {shown} lines'
|
summary = f'Log file size: {size_str}. Showing {shown} lines.'
|
||||||
return ''.join(tail).strip(), f'<p class="text-muted" style="margin-top:0.5em;">{summary}</p>'
|
return ''.join(tail).strip(), f'<p class="text-muted" style="margin-top:0.5em;">{summary}</p>'
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
return '(log file not found)', ''
|
return '(log file not found)', ''
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue