diff --git a/plinth/modules/help/help.py b/plinth/modules/help/help.py index 476bb73a1..9a8fda53e 100644 --- a/plinth/modules/help/help.py +++ b/plinth/modules/help/help.py @@ -73,15 +73,15 @@ def manual(request): 'content': content}) -def status_logs(request): +def status_log(request): """Serve the last 100 lines of plinth's status log""" num_lines = 100 - logfile = open(cfg.status_log_file, 'r') - data = logfile.readlines() + with open(cfg.status_log_file, 'r') as log_file: + data = log_file.readlines() + data = ''.join(data[-num_lines:]) context = { 'num_lines': num_lines, 'data': data } - logfile.close() return TemplateResponse(request, 'statuslog.html', context) diff --git a/plinth/modules/help/templates/statuslog.html b/plinth/modules/help/templates/statuslog.html index bed2cae63..f7f5917ca 100644 --- a/plinth/modules/help/templates/statuslog.html +++ b/plinth/modules/help/templates/statuslog.html @@ -1,46 +1,49 @@ {% extends 'help_base.html' %} {% comment %} - # - # This file is part of Plinth. - # - # This program is free software: you can redistribute it and/or modify - # it under the terms of the GNU Affero General Public License as - # published by the Free Software Foundation, either version 3 of the - # License, or (at your option) any later version. - # - # This program is distributed in the hope that it will be useful, - # but WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - # GNU Affero General Public License for more details. - # - # You should have received a copy of the GNU Affero General Public License - # along with this program. If not,see . - # +# +# This file is part of Plinth. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# {% endcomment %} {% load i18n %} {% block content %} -

- {% blocktrans trimmed %} - This is the last {{ num_lines }} lines of the status log for this web - interface. If you want to report a bug, please use the - bugtracker and - attach this status log to the bug report. - {% endblocktrans %} -

+

{% trans "Status Log" %}

-

- - {% blocktrans trimmed %} - Caution: Please remove any passwords or other personal information from the - log, before submitting the bug report. - {% endblocktrans %} - -

+

+ {% 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 + bug tracker and + attach this status log to the bug report. + {% endblocktrans %} +

+ +

+ + {% trans "Caution:" %} + {% blocktrans trimmed %} + Please remove any passwords or other personal information from + the log before submitting the bug report. + {% endblocktrans %} +

+ +

+

{{ data }}
+

-

-

{{ data }}
-

{% endblock %} diff --git a/plinth/modules/help/urls.py b/plinth/modules/help/urls.py index 3e553cf75..2ebb16220 100644 --- a/plinth/modules/help/urls.py +++ b/plinth/modules/help/urls.py @@ -32,5 +32,5 @@ urlpatterns = [ url(r'^help/index/$', views.index, name='index_explicit'), url(r'^help/about/$', views.about, name='about'), url(r'^help/manual/$', views.manual, name='manual'), - url(r'^help/status-logs/$', views.status_logs, name='status-logs'), + url(r'^help/status-log/$', views.status_log, name='status-log'), ] diff --git a/plinth/templates/500.html b/plinth/templates/500.html index ded166905..2fbb14a48 100644 --- a/plinth/templates/500.html +++ b/plinth/templates/500.html @@ -25,12 +25,13 @@

{% trans "500" %}

+ {% url 'help:status-log' as status_log_url %} {% blocktrans trimmed %} This is an internal error and not something you caused or can fix. Please report the error on the bug tracker so we can fix it. Also, please attach the - Status Log to the bug report. + status log to the bug report. {% endblocktrans %}