mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-19 21:03:21 -07:00
Add log level filter to PlexPy logs
This commit is contained in:
parent
7cb7783a34
commit
13ab4a9363
2 changed files with 102 additions and 65 deletions
|
@ -21,19 +21,31 @@
|
|||
<span><i class="fa fa-list-alt"></i> Logs</span>
|
||||
</div>
|
||||
<div class="button-bar">
|
||||
<div class="btn-group" id="filter-logs" style="display: none; ">
|
||||
<label>
|
||||
<select name="log-filter" id="log-filter" class="btn" style="color: inherit;">
|
||||
<option value="">All log levels</option>
|
||||
<option disabled>────────────</option>
|
||||
<option value="DEBUG">Debug</option>
|
||||
<option value="INFO">Info</option>
|
||||
<option value="WARN">Warning</option>
|
||||
<option value="ERROR">Error</option>
|
||||
</select>
|
||||
</label>
|
||||
<div class="btn-group" id="plexpy-log-levels">
|
||||
<label>
|
||||
<select name="plexpy-log-level-filter" id="plexpy-log-level-filter" class="btn" style="color: inherit;">
|
||||
<option value="">All log levels</option>
|
||||
<option disabled>────────────</option>
|
||||
<option value="DEBUG">Debug</option>
|
||||
<option value="INFO">Info</option>
|
||||
<option value="WARN">Warning</option>
|
||||
<option value="ERROR">Error</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<button class="btn btn-dark" id="download-plexpylog"><i class="fa fa-download"></i> Download log</button>
|
||||
<div class="btn-group" id="plex-log-levels" style="display: none;">
|
||||
<label>
|
||||
<select name="plex-log-level-filter" id="plex-log-level-filter" class="btn" style="color: inherit;">
|
||||
<option value="">All log levels</option>
|
||||
<option disabled>────────────</option>
|
||||
<option value="DEBUG">Debug</option>
|
||||
<option value="INFO">Info</option>
|
||||
<option value="WARN">Warning</option>
|
||||
<option value="ERROR">Error</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<button class="btn btn-dark" id="clear-logs"><i class="fa fa-trash-o"></i> Clear logs</button>
|
||||
<button class="btn btn-dark" id="clear-notify-logs" style="display: none;"><i class="fa fa-trash-o"></i> Clear logs</button>
|
||||
<button class="btn btn-dark" id="clear-login-logs" style="display: none;"><i class="fa fa-trash-o"></i> Clear logs</button>
|
||||
|
@ -52,24 +64,23 @@
|
|||
<div role="tabpanel" class="tab-pane active" id="tabs-1">
|
||||
<table class="display" id="log_table" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="min-tablet" align="left" id="timestamp">Timestamp</th>
|
||||
<th class="desktop" align="left" id="level">Level</th>
|
||||
<th class="all" align="left" id="message">Message</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="min-tablet" align="left" id="timestamp">Timestamp</th>
|
||||
<th class="desktop" align="left" id="level">Level</th>
|
||||
<th class="all" align="left" id="message">Message</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane" id="tabs-2">
|
||||
<table class="display" id="plex_log_table" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="left" id="plex_timestamp">Timestamp</th>
|
||||
<th align="left" id="plex_level">Level</th>
|
||||
<th align="left" id="plex_message">Message</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="left" id="plex_timestamp">Timestamp</th>
|
||||
<th align="left" id="plex_level">Level</th>
|
||||
<th align="left" id="plex_message">Message</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
|
@ -126,7 +137,8 @@
|
|||
</div>
|
||||
|
||||
<br>
|
||||
<div align="center">Refresh rate:
|
||||
<div align="center">
|
||||
Refresh rate:
|
||||
<select id="refreshrate" onchange="setRefresh()">
|
||||
<option value="0" selected="selected">No Refresh</option>
|
||||
<option value="5">5 Seconds</option>
|
||||
|
@ -151,43 +163,55 @@
|
|||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
loadPlexPyLogs();
|
||||
clearSearchButton('log_table', log_table);
|
||||
loadPlexPyLogs(selected_log_level);
|
||||
});
|
||||
|
||||
var log_levels = ['DEBUG', 'INFO', 'WARN', 'ERROR'];
|
||||
|
||||
function bindLogLevelFilter() {
|
||||
clearLogLevelFilter();
|
||||
var log_level_column = this.api().column(1);
|
||||
var select = $('#log-filter');
|
||||
select.on('change', function() {
|
||||
var val = $.fn.dataTable.util.escapeRegex(
|
||||
$(this).val()
|
||||
);
|
||||
var search_string = '';
|
||||
var levelIndex = log_levels.indexOf(val);
|
||||
if (levelIndex >= 0) {
|
||||
search_string = '^' + log_levels
|
||||
.slice(levelIndex)
|
||||
.join('|') + '$';
|
||||
}
|
||||
|
||||
log_level_column
|
||||
.search(search_string, true, false )
|
||||
.draw();
|
||||
}).change();
|
||||
clearLogLevelFilter();
|
||||
var log_level_column = this.api().column(1);
|
||||
var select = $('#plex-log-level-filter');
|
||||
select.on('change', function () {
|
||||
var val = $.fn.dataTable.util.escapeRegex(
|
||||
$(this).val()
|
||||
);
|
||||
var search_string = '';
|
||||
var levelIndex = log_levels.indexOf(val);
|
||||
if (levelIndex >= 0) {
|
||||
search_string = '^' + log_levels
|
||||
.slice(levelIndex)
|
||||
.join('|') + '$';
|
||||
}
|
||||
log_level_column
|
||||
.search(search_string, true, false)
|
||||
.draw();
|
||||
}).change();
|
||||
}
|
||||
|
||||
function clearLogLevelFilter() {
|
||||
$('#log-filter').off('change');
|
||||
$('#plex-log-level-filter').off('change');
|
||||
}
|
||||
|
||||
function loadPlexPyLogs() {
|
||||
var selected_log_level = null;
|
||||
function loadPlexPyLogs(selected_log_level) {
|
||||
log_table_options.ajax = {
|
||||
url: "getLog"
|
||||
url: "getLog",
|
||||
type: 'post',
|
||||
data: function (d) {
|
||||
return {
|
||||
json_data: JSON.stringify(d),
|
||||
log_level: selected_log_level
|
||||
};
|
||||
}
|
||||
}
|
||||
log_table = $('#log_table').DataTable(log_table_options);
|
||||
clearSearchButton('log_table', log_table);
|
||||
|
||||
$('#plexpy-log-level-filter').on('change', function () {
|
||||
selected_log_level = $(this).val() || null;
|
||||
log_table.draw();
|
||||
});
|
||||
}
|
||||
|
||||
function loadPlexLogs() {
|
||||
|
@ -232,17 +256,19 @@
|
|||
}
|
||||
|
||||
$("#plexpy-logs-btn").click(function () {
|
||||
$("#filter-logs").hide();
|
||||
$("#plexpy-log-levels").show();
|
||||
$("#plex-log-levels").hide();
|
||||
$("#clear-logs").show();
|
||||
$("#download-plexpylog").show()
|
||||
$("#clear-notify-logs").hide();
|
||||
$("#clear-login-logs").hide();
|
||||
loadPlexPyLogs();
|
||||
loadPlexPyLogs(selected_log_level);
|
||||
clearSearchButton('log_table', log_table);
|
||||
});
|
||||
|
||||
$("#plex-logs-btn").click(function () {
|
||||
$("#filter-logs").show();
|
||||
$("#plexpy-log-levels").hide();
|
||||
$("#plex-log-levels").show();
|
||||
$("#clear-logs").hide();
|
||||
$("#download-plexpylog").hide()
|
||||
$("#clear-notify-logs").hide();
|
||||
|
@ -252,7 +278,8 @@
|
|||
});
|
||||
|
||||
$("#plex-scanner-logs-btn").click(function () {
|
||||
$("#filter-logs").show();
|
||||
$("#plexpy-log-levels").hide();
|
||||
$("#plex-log-levels").show();
|
||||
$("#clear-logs").hide();
|
||||
$("#download-plexpylog").hide()
|
||||
$("#clear-notify-logs").hide();
|
||||
|
@ -262,7 +289,8 @@
|
|||
});
|
||||
|
||||
$("#notification-logs-btn").click(function () {
|
||||
$("#filter-logs").hide();
|
||||
$("#plexpy-log-levels").hide();
|
||||
$("#plex-log-levels").hide();
|
||||
$("#clear-logs").hide();
|
||||
$("#download-plexpylog").hide()
|
||||
$("#clear-notify-logs").show();
|
||||
|
@ -272,7 +300,8 @@
|
|||
});
|
||||
|
||||
$("#login-logs-btn").click(function () {
|
||||
$("#filter-logs").hide();
|
||||
$("#plexpy-log-levels").hide();
|
||||
$("#plex-log-levels").hide();
|
||||
$("#clear-logs").hide();
|
||||
$("#download-plexpylog").hide()
|
||||
$("#clear-notify-logs").hide();
|
||||
|
|
|
@ -34,6 +34,7 @@ import config
|
|||
import database
|
||||
import datafactory
|
||||
import graphs
|
||||
import helpers
|
||||
import http_handler
|
||||
import libraries
|
||||
import log_reader
|
||||
|
@ -2233,13 +2234,15 @@ class WebInterface(object):
|
|||
|
||||
@cherrypy.expose
|
||||
@requireAuth(member_of("admin"))
|
||||
def getLog(self, start=0, length=100, **kwargs):
|
||||
start = int(start)
|
||||
length = int(length)
|
||||
order_dir = kwargs.get('order[0][dir]', "desc")
|
||||
order_column = kwargs.get('order[0][column]', "0")
|
||||
search_value = kwargs.get('search[value]', "")
|
||||
search_regex = kwargs.get('search[regex]', "") # Remove?
|
||||
def getLog(self, **kwargs):
|
||||
json_data = helpers.process_json_kwargs(json_kwargs=kwargs.get('json_data'))
|
||||
log_level = kwargs.get('log_level', "")
|
||||
|
||||
start = json_data['start']
|
||||
length = json_data['length']
|
||||
order_column = json_data['order'][0]['column']
|
||||
order_dir = json_data['order'][0]['dir']
|
||||
search_value = json_data['search']['value']
|
||||
sortcolumn = 0
|
||||
|
||||
filt = []
|
||||
|
@ -2250,7 +2253,7 @@ class WebInterface(object):
|
|||
try:
|
||||
temp_loglevel_and_time = l.split(' - ', 1)
|
||||
loglvl = temp_loglevel_and_time[1].split(' ::', 1)[0].strip()
|
||||
msg = l.split(' : ', 1)[1].replace('\n', '')
|
||||
msg = unicode(l.split(' : ', 1)[1].replace('\n', ''), 'utf-8')
|
||||
fa([temp_loglevel_and_time[0], loglvl, msg])
|
||||
except IndexError:
|
||||
# Add traceback message to previous msg.
|
||||
|
@ -2260,10 +2263,15 @@ class WebInterface(object):
|
|||
filt[tl][2] += '<br>' + l
|
||||
continue
|
||||
|
||||
if search_value == '':
|
||||
filtered = filt
|
||||
log_levels = ['DEBUG', 'INFO', 'WARN', 'ERROR']
|
||||
if log_level in log_levels:
|
||||
log_levels = log_levels[log_levels.index(log_level)::]
|
||||
filtered = [row for row in filt if row[1] in log_levels]
|
||||
else:
|
||||
filtered = [row for row in filt for column in row if search_value.lower() in column.lower()]
|
||||
filtered = filt
|
||||
|
||||
if search_value:
|
||||
filtered = [row for row in filtered for column in row if search_value.lower() in column.lower()]
|
||||
|
||||
if order_column == '1':
|
||||
sortcolumn = 2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue