mirror of
https://github.com/morpheus65535/bazarr
synced 2025-01-30 19:02:34 +00:00
Some logging improvements
This commit is contained in:
parent
d7364f87c1
commit
501aab3ff5
2 changed files with 35 additions and 11 deletions
|
@ -1683,16 +1683,23 @@ def system():
|
|||
releases=releases, current_port=settings.general.port, throttled_providers=throttled_providers)
|
||||
|
||||
|
||||
@route(base_url + 'logs/<page:int>')
|
||||
@route(base_url + 'logs/<level>/<page:int>')
|
||||
@custom_auth_basic(check_credentials)
|
||||
def get_logs(page):
|
||||
def get_logs(level, page):
|
||||
authorize()
|
||||
page_size = int(settings.general.page_size)
|
||||
begin = (page * page_size) - page_size
|
||||
end = (page * page_size) - 1
|
||||
logs_complete = []
|
||||
for line in reversed(open(os.path.join(args.config_dir, 'log', 'bazarr.log')).readlines()):
|
||||
logs_complete.append(line.rstrip())
|
||||
lin = []
|
||||
lin = line.split('|')
|
||||
if 'ALL' in level or level is None:
|
||||
logs_complete.append(line.rstrip())
|
||||
else:
|
||||
if level in lin[1]:
|
||||
logs_complete.append(line.rstrip())
|
||||
|
||||
logs = logs_complete[begin:end]
|
||||
|
||||
return template('logs', logs=logs, base_url=base_url, current_port=settings.general.port)
|
||||
|
|
|
@ -105,6 +105,16 @@
|
|||
<button id="download_log" class="ui button"><i class="download icon"></i>Download log file</button>
|
||||
<button id="empty_log" class="ui button"><i class="download icon"></i>Empty log file</button>
|
||||
</div>
|
||||
|
||||
<label>Log level filter:</label>
|
||||
<select name="level" id="level" class="ui floated selection dropdown">
|
||||
<option value="ALL">All</option>
|
||||
<option value="WARNING">WARNING</option>
|
||||
<option value="INFO">INFO</option>
|
||||
<option value="ERROR">ERROR</option>
|
||||
<option value="DEBUG">DEBUG</option>
|
||||
</select>
|
||||
|
||||
|
||||
<div class="content">
|
||||
<div id="logs"></div>
|
||||
|
@ -324,9 +334,9 @@
|
|||
$('.menu .item')
|
||||
.tab();
|
||||
|
||||
function loadURL(page) {
|
||||
function loadURL(level, page) {
|
||||
$.ajax({
|
||||
url: "{{base_url}}logs/" + page,
|
||||
url: "{{base_url}}logs/" + level + "/" + page,
|
||||
beforeSend: function() { $('#loader').addClass('active'); },
|
||||
complete: function() { $('#loader').removeClass('active'); },
|
||||
cache: false
|
||||
|
@ -335,6 +345,9 @@
|
|||
});
|
||||
|
||||
current_page = page;
|
||||
$('#level').on('change', function() {
|
||||
current_level = $('#level option:checked').val();
|
||||
});
|
||||
|
||||
$("#page").text(current_page);
|
||||
if (current_page == 1) {
|
||||
|
@ -349,23 +362,27 @@
|
|||
}
|
||||
}
|
||||
|
||||
loadURL(1);
|
||||
loadURL('ALL', 1);
|
||||
|
||||
$('.backward').on('click', function(){
|
||||
loadURL(current_page - 1);
|
||||
loadURL(current_level, current_page - 1);
|
||||
});
|
||||
$('.fast.backward').on('click', function(){
|
||||
loadURL(1);
|
||||
loadURL(current_level, 1);
|
||||
});
|
||||
$('.forward').on('click', function(){
|
||||
loadURL(current_page + 1);
|
||||
loadURL(current_level, current_page + 1);
|
||||
});
|
||||
$('.fast.forward').on('click', function(){
|
||||
loadURL({{int(max_page)}});
|
||||
loadURL(current_level, {{int(max_page)}});
|
||||
});
|
||||
|
||||
$('#refresh_log').on('click', function(){
|
||||
loadURL(current_page);
|
||||
loadURL(current_level, current_page);
|
||||
});
|
||||
|
||||
$('#level').on('change', function(){
|
||||
loadURL(current_level, current_page);
|
||||
});
|
||||
|
||||
$('#download_log').on('click', function(){
|
||||
|
|
Loading…
Reference in a new issue