pull/884/head
Louis Vézina 5 years ago
parent 630f7e8394
commit 7cfa3fe337

@ -60,6 +60,18 @@ class Languages(Resource):
return jsonify(result)
class SystemLogs(Resource):
def get(self):
logs = []
with io.open(os.path.join(args.config_dir, 'log', 'bazarr.log'), encoding='UTF-8') as file:
for line in file.readlines():
lin = []
lin = line.split('|')
logs.append(lin)
logs.reverse()
return jsonify(data=logs)
class SystemStatus(Resource):
def get(self):
system_status = {}
@ -1078,6 +1090,7 @@ class SearchWantedMovies(Resource):
api.add_resource(Badges, '/badges')
api.add_resource(Languages, '/languages')
api.add_resource(SystemLogs, '/systemlogs')
api.add_resource(SystemStatus, '/systemstatus')
api.add_resource(SystemReleases, '/systemreleases')

@ -1016,6 +1016,12 @@ def check_update():
redirect(ref)
@app.route('/systemlogs')
@login_required
def systemlogs():
return render_template('systemlogs.html')
@app.route('/systemstatus')
@login_required
def systemstatus():

@ -189,7 +189,7 @@
class="fas fa-laptop"></i><span class="hide-menu"> System</span></a>
<ul aria-expanded="false" class="collapse">
<li><a href="/"> Tasks</a></li>
<li><a href="/"> Logs</a></li>
<li><a href="{{ url_for('systemlogs') }}"> Logs</a></li>
<li><a href="/"> Providers</a></li>
<li><a href="{{ url_for('systemstatus') }}"> Status</a></li>
<li><a href="{{ url_for('systemreleases') }}"> Releases</a></li>
@ -269,6 +269,7 @@
<script src="{{ url_for('static',filename='js/custom.js') }}"></script>
<script src="{{ url_for('static',filename='js/socket.io.js') }}"></script>
<script src="{{ url_for('static',filename='js/bootstrap-select.min.js') }}"></script>
<script src="{{ url_for('static',filename='moment/moment.js') }}"></script>
<script>
$(document).ready(function () {

@ -0,0 +1,130 @@
{% extends '_main.html' %}
{% block title %}Logs - Bazarr{% endblock %}
{% block bcleft %}
<div class="">
<button class="btn btn-outline" id="refresh_button">
<div><i class="fas fa-sync align-top text-themecolor text-center font-20" aria-hidden="true"></i></div>
<div class="align-bottom text-themecolor small text-center">Refresh</div>
</button>
<button class="btn btn-outline" id="download_button">
<div><i class="fas fa-download align-top text-themecolor text-center font-20" aria-hidden="true"></i></div>
<div class="align-bottom text-themecolor small text-center">Download</div>
</button>
<button class="btn btn-outline" id="empty_button">
<div><i class="fas fa-trash align-top text-themecolor text-center font-20" aria-hidden="true"></i></div>
<div class="align-bottom text-themecolor small text-center">Empty</div>
</button>
</div>
{% endblock bcleft %}
{% block bcright %}
<div class="d-flex m-t-5 justify-content-end">
<button class="btn btn-outline" class="dropdown">
<div class="dropdown-toggle" data-toggle="dropdown"><i class="fas fa-filter align-top text-themecolor text-center font-20" aria-hidden="true"></i></div>
<div class="align-bottom text-themecolor small text-center">Filter</div>
<div class="dropdown-menu dropdown-menu-right scale-up">
<a href="" class="dropdown-item"><i class="far fa-circle" style="color: black;"></i> All</a>
<a href="" class="dropdown-item"><i class="fas fa-info-circle" style="color: #1e90ff;"></i> Info</a>
<a href="" class="dropdown-item"><i class="fas fa-exclamation-circle" style="color: yellow;"></i> Warning</a>
<a href="" class="dropdown-item"><i class="fas fa-bug" style="color: red;"></i> Error</a>
<a href="" class="dropdown-item"><i class="fas fa-bug" style="color: black;"></i> Debug</a>
</div>
</button>
</div>
{% endblock bcright %}
{% block body %}
<div class="container-fluid">
<table id="logs" class="table table-striped" style="width:100%">
<thead>
<tr>
<th></th>
<th></th>
<th>Message:</th>
<th>Time:</th>
<th></th>
</tr>
</thead>
</table>
</div>
{% endblock body %}
{% block tail %}
<script>
$(document).ready(function () {
var table = $('#logs').DataTable( {
language: {
zeroRecords: 'No entries found in logs matching this log level.',
processing: "Loading Logs..."
},
paging: true,
lengthChange: false,
pageLength: {{ settings.general.page_size }},
searching: true,
search: {
regex: true
},
ordering: false,
processing: true,
serverSide: false,
ajax: "{{ url_for('api.systemlogs') }}",
columns: [
{
data: 1,
render: function (data) {
return $.trim(data);
}
},
{ data: 1,
render: function (data) {
var icon;
switch ($.trim(data)) {
case 'INFO':
icon = '"fas fa-info-circle" style="color: #1e90ff;"';
break;
case 'WARNING':
icon = '"fas fa-exclamation-circle" style="color: yellow;"';
break;
case 'ERROR':
icon = '"fas fa-bug" style="color: red;"';
break;
case 'DEBUG':
icon = '"fas fa-bug" style="color: black;"';
}
return '<i class=' + icon + '></i>';
}
},
{ data: 3,
render: function (data) {
return $.trim(data);
}
},
{ data: 0,
render: function (data) {
return '<div class="description" data-toggle="tooltip" data-title="' + $.trim(data) + '">' + moment($.trim(data), "DD/MM/YYYY hh:mm:ss").fromNow() + '</div>'
}
},
{ data: 4,
render: function (data) {
return $.trim(data);
}
}
],
columnDefs: [
{
"targets": [ 0 ],
"visible": false,
"searchable": true
},
{
"targets": [ 4 ],
"visible": false,
"searchable": false
}
]
} );
})
</script>
{% endblock tail %}
Loading…
Cancel
Save