mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
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:
1 parent
e82d959c85
commit
5a55b59939
7 files changed
+20
-106
No files matched your search
@@ -1,14 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""Actions for help module."""
|
||||
|
||||
import subprocess
|
||||
|
||||
from plinth.actions import privileged
|
||||
|
||||
|
||||
@privileged
|
||||
def get_logs() -> str:
|
||||
"""Get latest FreedomBox logs."""
|
||||
command = ['journalctl', '--no-pager', '--lines=100', '--unit=plinth']
|
||||
process = subprocess.run(command, check=True, stdout=subprocess.PIPE)
|
||||
return process.stdout.decode()
|
||||
@@ -1,38 +0,0 @@
|
||||
{% extends 'help_base.html' %}
|
||||
{% comment %}
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
{% endcomment %}
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h2>{% trans "Status Log" %}</h2>
|
||||
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
These are the last {{ num_lines }} lines of the status log for this web
|
||||
interface. If you want to report a bug, please use the <a
|
||||
href="https://salsa.debian.org/freedombox-team/freedombox/issues">bug
|
||||
tracker</a> and attach this status log to the bug report.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
|
||||
<div class="alert alert-warning d-flex align-items-center">
|
||||
<div class="me-2">
|
||||
<span class="fa fa-exclamation-triangle" aria-hidden="true"></span>
|
||||
<span class="visually-hidden">{% trans "Caution:" %}</span>
|
||||
</div>
|
||||
<div>
|
||||
{% blocktrans trimmed %}
|
||||
Please remove any personal information from the log before submitting
|
||||
the bug report.
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<pre class="status-log">{{ data }}</pre>
|
||||
</p>
|
||||
|
||||
{% endblock %}
|
||||
@@ -1,38 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
Functional, browser based tests for help app.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
from plinth.tests import functional
|
||||
|
||||
pytestmark = [pytest.mark.system, pytest.mark.essential, pytest.mark.help]
|
||||
|
||||
# TODO Scenario: Visit the wiki
|
||||
# TODO Scenario: Visit the mailing list
|
||||
# TODO Scenario: Visit the IRC channel
|
||||
# TODO Scenario: View the manual
|
||||
# TODO Scenario: View the about page
|
||||
|
||||
|
||||
@pytest.fixture(scope='module', autouse=True)
|
||||
def fixture_background(session_browser):
|
||||
"""Login."""
|
||||
functional.login(session_browser)
|
||||
|
||||
|
||||
def test_view_status_logs(session_browser):
|
||||
"""Test viewing the status logs."""
|
||||
_go_to_status_logs(session_browser)
|
||||
assert _are_status_logs_shown(session_browser)
|
||||
|
||||
|
||||
def _go_to_status_logs(browser):
|
||||
functional.visit(browser, '/plinth/help/status-log/')
|
||||
|
||||
|
||||
def _are_status_logs_shown(browser):
|
||||
status_log = browser.find_by_css('.status-log').first.text
|
||||
return ('-- No entries --' in status_log
|
||||
or status_log.strip().splitlines())
|
||||
@@ -25,6 +25,4 @@ urlpatterns = [
|
||||
non_admin_view(views.manual), name='manual-page'),
|
||||
re_path(r'^help/manual-download/$', non_admin_view(views.download_manual),
|
||||
name='download-manual'),
|
||||
re_path(r'^help/status-log/$', non_admin_view(views.status_log),
|
||||
name='status-log'),
|
||||
]
|
||||
@@ -19,8 +19,6 @@ from django.utils.translation import gettext as _
|
||||
from plinth import __version__, cfg, menu
|
||||
from plinth.modules.upgrades import views as upgrades_views
|
||||
|
||||
from . import privileged
|
||||
|
||||
|
||||
def index(request):
|
||||
"""Serve the index page"""
|
||||
@@ -164,10 +162,3 @@ def download_manual(request):
|
||||
response['Content-Encoding'] = encoding
|
||||
|
||||
return response
|
||||
|
||||
|
||||
def status_log(request):
|
||||
"""Serve the last 100 lines of plinth's status log."""
|
||||
logs = privileged.get_logs()
|
||||
context = {'num_lines': 100, 'data': logs}
|
||||
return TemplateResponse(request, 'statuslog.html', context)
|
||||
Reference in new issue
Block a user