diagnostics, help: Link to diagnostics page logs in 500 error page

Closes: #2414.

- Remove separate implementation for showing logs in help page.

- Add link to the page in diagnostics app so that FreedomBox logs can more
easily be discovered by users.

Tests:

- Raise an exception in the common error middleware to cause a 500 internal
server error. Run FreedomBox service with the --develop option and notice that
500 error page is served. There, the link to logs page works. It shows the logs
for Diagnostics app.

- Diagnostics page description is update. Link to logs page works.

- Diagnostics page shows logs for plinth.service and freedombox-develop.service.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Sunil Mohan Adapa authored and Veiko Aasa committed 2025-09-18 16:35:23 +03:00
1 parent e82d959c85
commit 5a55b59939
7 files changed
+20 -106

No files matched your search

+18 -3
View File
@@ -11,24 +11,31 @@ import threading
from copy import deepcopy
import psutil
from django.urls import reverse_lazy
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext_noop
from plinth import app as app_module
from plinth import daemon, glib, kvstore, menu
from plinth import cfg, glib, kvstore, menu
from plinth import operation as operation_module
from plinth.daemon import RelatedDaemon, diagnose_port_listening
from plinth.diagnostic_check import (CheckJSONDecoder, CheckJSONEncoder,
DiagnosticCheck, Result)
from plinth.modules.apache.components import diagnose_url_on_all
from plinth.modules.backups.components import BackupRestore
from plinth.setup import run_repair_on_app
from plinth.utils import format_lazy
from . import manifest
_description = [
_('The system diagnostic test will run a number of checks on your '
'system to confirm that applications and services are working as '
'expected.')
'expected.'),
format_lazy(
_('This app also shows the <a href="{logs_url}">logs</a> for '
'{box_name} services.'), box_name=_(cfg.box_name),
logs_url=reverse_lazy('logs', args=['diagnostics']))
]
logger = logging.Logger(__name__)
@@ -61,6 +68,14 @@ class DiagnosticsApp(app_module.App):
order=30)
self.add(menu_item)
# Add FreedomBox daemons to show logs for them.
daemon = RelatedDaemon('related-daemon-plinth', 'plinth')
self.add(daemon)
daemon = RelatedDaemon('related-daemon-freedombox-privileged',
'freedombox-privileged')
self.add(daemon)
backup_restore = BackupRestore('backup-restore-diagnostics',
**manifest.backup)
self.add(backup_restore)
@@ -82,7 +97,7 @@ class DiagnosticsApp(app_module.App):
def diagnose(self) -> list[DiagnosticCheck]:
"""Run diagnostics and return the results."""
results = super().diagnose()
results.append(daemon.diagnose_port_listening(8000, 'tcp4'))
results.append(diagnose_port_listening(8000, 'tcp4'))
results.extend(
diagnose_url_on_all('http://{host}/plinth/',
check_certificate=False))