mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 16:44:39 +00:00
Logging: add "step into" icon on log lines. Since we always read the complete file, we can know the actual row number of a search result.
When investigating log files it's often practical to see the context of a message after searching for it. This feature offers the ability to go to the page in question by clicking on a filtered result.
This commit is contained in:
parent
36e03d8681
commit
0841c5a877
@ -26,16 +26,40 @@
|
||||
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
$("#grid-log").UIBootgrid({
|
||||
let grid_log = $("#grid-log").UIBootgrid({
|
||||
options:{
|
||||
sorting:false,
|
||||
rowSelect: false,
|
||||
selection: false,
|
||||
rowCount:[20,50,100,200,500,1000,-1],
|
||||
formatters:{
|
||||
page: function (column, row) {
|
||||
if ($("input.search-field").val() !== "") {
|
||||
return "<button type=\"button\" class=\"btn btn-xs btn-default action-page\" data-row-id=\"" +
|
||||
row.rnum +
|
||||
"\"><span class=\"fa fa-arrow-right fa-fw\"></span></button>";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
search:'/api/diagnostics/log/{{module}}/{{scope}}'
|
||||
});
|
||||
|
||||
grid_log.on("loaded.rs.jquery.bootgrid", function(){
|
||||
$(".action-page").click(function(event){
|
||||
event.preventDefault();
|
||||
$("#grid-log").bootgrid("search", "");
|
||||
let new_page = parseInt((parseInt($(this).data('row-id')) / $("#grid-log").bootgrid("getRowCount")))+1;
|
||||
$("input.search-field").val("");
|
||||
// XXX: a bit ugly, but clearing the filter triggers a load event.
|
||||
setTimeout(function(){
|
||||
$("ul.pagination > li:last > a").data('page', new_page).click();
|
||||
}, 100);
|
||||
});
|
||||
});
|
||||
|
||||
$("#flushlog").on('click', function(event){
|
||||
event.preventDefault();
|
||||
BootstrapDialog.show({
|
||||
@ -76,10 +100,10 @@
|
||||
<table id="grid-log" class="table table-condensed table-hover table-striped table-responsive" data-store-selection="true">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="pos" data-type="numeric" data-identifier="true" data-visible="false">#</th>
|
||||
<th data-column-id="timestamp" data-width="11em" data-type="string">{{ lang._('Date') }}</th>
|
||||
<th data-column-id="process_name" data-width="2em" data-type="string">{{ lang._('Process') }}</th>
|
||||
<th data-column-id="line" data-type="string">{{ lang._('Line') }}</th>
|
||||
<th data-column-id="rnum" data-type="numeric" data-formatter="page" data-width="2em"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
@ -83,6 +83,7 @@ if __name__ == '__main__':
|
||||
# remove illegal expression
|
||||
filter_regexp = re.compile('.*')
|
||||
|
||||
row_number = 0
|
||||
for log_filename in log_filenames:
|
||||
if os.path.exists(log_filename):
|
||||
format_container = FormatContainer(log_filename)
|
||||
@ -91,13 +92,15 @@ if __name__ == '__main__':
|
||||
except Exception as e:
|
||||
filename = log_filename
|
||||
for rec in reverse_log_reader(filename):
|
||||
row_number += 1
|
||||
if rec['line'] != "" and filter_regexp.match(('%s' % rec['line']).lower()):
|
||||
result['total_rows'] += 1
|
||||
if (len(result['rows']) < limit or limit == 0) and result['total_rows'] >= offset:
|
||||
record = {
|
||||
'timestamp': None,
|
||||
'parser': None,
|
||||
'process_name': ''
|
||||
'process_name': '',
|
||||
'rnum': row_number
|
||||
}
|
||||
frmt = format_container.get_format(rec['line'])
|
||||
if frmt:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user