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():
|
||||
log_path = f'{CONFIGS_DIR}/ddns.log'
|
||||
try:
|
||||
size_kb = os.path.getsize(log_path) / 1024
|
||||
with open(log_path) as f:
|
||||
lines = f.readlines()
|
||||
if not lines:
|
||||
|
|
@ -473,10 +474,11 @@ def _ddns_log_tail():
|
|||
tail = lines[-DDNS_LOG_MAX:]
|
||||
shown = len(tail)
|
||||
hidden = total - shown
|
||||
size_str = f'{size_kb:.1f}KB'
|
||||
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:
|
||||
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>'
|
||||
except FileNotFoundError:
|
||||
return '(log file not found)', ''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue