diff --git a/docker/routlin-dash/app/view_page.py b/docker/routlin-dash/app/view_page.py index 49669c9..390bfff 100644 --- a/docker/routlin-dash/app/view_page.py +++ b/docker/routlin-dash/app/view_page.py @@ -460,16 +460,28 @@ def _blocklist_stats_html(core): ) -def _ddns_log_tail(n=50): +DDNS_LOG_MAX = 50 + +def _ddns_log_tail(): log_path = f'{CONFIGS_DIR}/ddns.log' try: with open(log_path) as f: lines = f.readlines() - return ''.join(lines[-n:]).strip() or '(log is empty)' + if not lines: + return '(log is empty)', '' + total = len(lines) + tail = lines[-DDNS_LOG_MAX:] + shown = len(tail) + hidden = total - shown + if hidden > 0: + summary = f'Showing last {shown} lines ({hidden} lines not shown)' + else: + summary = f'Showing {shown} lines' + return ''.join(tail).strip(), f'

{summary}

' except FileNotFoundError: - return '(log file not found)' + return '(log file not found)', '' except Exception: - return '(error reading log)' + return '(error reading log)', '' def _fmt_seconds(secs): secs = int(secs) @@ -696,7 +708,7 @@ def collect_tokens(): tokens['STAT_PUBLIC_IP'] = ip_str tokens['STAT_DDNS_HOSTNAME'] = sub_str tokens['STAT_DDNS_NEXT_INTERVAL'] = next_interval - tokens['DDNS_LOG_TAIL'] = _ddns_log_tail() + tokens['DDNS_LOG_TAIL'], tokens['DDNS_LOG_SUMMARY'] = _ddns_log_tail() tokens['STAT_UPTIME'] = _run('uptime -p') or '-' tokens['STAT_NFTABLES_STATUS'] = 'Active' if _run('nft list tables 2>/dev/null').strip() else 'Inactive' diff --git a/docker/routlin-dash/data/page_content.json b/docker/routlin-dash/data/page_content.json index 64ce911..7a480cb 100644 --- a/docker/routlin-dash/data/page_content.json +++ b/docker/routlin-dash/data/page_content.json @@ -456,6 +456,14 @@ "label": "DDNS Log", "client_requirement": "client_is_administrator+", "items": [ + { + "type": "pre_block", + "text": "%DDNS_LOG_TAIL%" + }, + { + "type": "raw_html", + "html": "%DDNS_LOG_SUMMARY%" + }, { "type": "button_row", "items": [ @@ -466,10 +474,6 @@ "text": "Clear Log" } ] - }, - { - "type": "pre_block", - "text": "%DDNS_LOG_TAIL%" } ] }