luci-app: updated log.

This commit is contained in:
gSpot
2024-02-27 17:31:44 +03:00
parent 9d0a75a7f8
commit c044d303c5
8 changed files with 74 additions and 75 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ LUCI_APP=1
OWRT_VERSION="current" OWRT_VERSION="current"
RUAB_VERSION="1.4-1" RUAB_VERSION="1.4-1"
RUAB_MOD_LUA_VERSION="1.4-0" RUAB_MOD_LUA_VERSION="1.4-0"
RUAB_LUCI_APP_VERSION="1.4-1" RUAB_LUCI_APP_VERSION="1.4-2"
BASE_URL="https://raw.githubusercontent.com/gSpotx2f/packages-openwrt/master" BASE_URL="https://raw.githubusercontent.com/gSpotx2f/packages-openwrt/master"
PKG_DIR="/tmp" PKG_DIR="/tmp"
+2 -2
View File
@@ -1,10 +1,10 @@
# #
# (с) 2023 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt) # (с) 2024 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt)
# #
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_VERSION:=1.4-1 PKG_VERSION:=1.4-2
LUCI_TITLE:=LuCI support for ruantiblock LUCI_TITLE:=LuCI support for ruantiblock
LUCI_DEPENDS:=+ruantiblock LUCI_DEPENDS:=+ruantiblock
LUCI_PKGARCH:=all LUCI_PKGARCH:=all
@@ -34,6 +34,11 @@ document.head.append(E('style', {'type': 'text/css'},
--app-log-debug: #5986b1; --app-log-debug: #5986b1;
--app-log-entries-count-border: #555; --app-log-entries-count-border: #555;
} }
#logWrapper {
overflow: auto !important;
width: 100%;
min-height: 20em';
}
.log-empty { .log-empty {
} }
.log-emerg { .log-emerg {
@@ -137,6 +142,8 @@ log-emerg td {
position: fixed; position: fixed;
z-index: 1 !important; z-index: 1 !important;
opacity: 0.7; opacity: 0.7;
right: 1px;
top: 40vh;
} }
.log-side-btn { .log-side-btn {
position: relative; position: relative;
@@ -881,8 +888,7 @@ return baseclass.extend({
this.pollFuncWrapper = L.bind(this.pollFunc, this); this.pollFuncWrapper = L.bind(this.pollFunc, this);
this.logWrapper = E('div', { this.logWrapper = E('div', {
'id' : 'logWrapper', 'id': 'logWrapper',
'style': 'width:100%; min-height:20em'
}, this.makeLogArea(this.parseLogData(logdata, this.tailValue))); }, this.makeLogArea(this.parseLogData(logdata, this.tailValue)));
this.fastTailValue = this.tailValue this.fastTailValue = this.tailValue
@@ -1045,7 +1051,6 @@ return baseclass.extend({
E('div', { E('div', {
'align': 'right', 'align': 'right',
'class': 'log-side-block', 'class': 'log-side-block',
'style': `right:1px; top:${window.innerHeight / 2 - 60}px`,
}, [ }, [
this.refreshBtn, this.refreshBtn,
this.moreEntriesBtn, this.moreEntriesBtn,
@@ -5,34 +5,24 @@
document.head.append(E('style', {'type': 'text/css'}, document.head.append(E('style', {'type': 'text/css'},
` `
.log-entry-empty { #logTable {
width: calc(100% - 4px);
} }
.log-entry-number { .log-entry-time-cell {
min-width: 4em !important; min-width: 14em !important;
}
.log-entry-time {
min-width: 15em !important;
}
.log-entry-host {
min-width: 10em !important;
} }
.log-entry-host-cell { .log-entry-host-cell {
word-break: break-all !important; min-width: 10em !important;
word-wrap: break-word !important; overflow-wrap: anywhere !important;
}
.log-entry-log-level {
max-width: 5em !important;
}
.log-entry-facility{
max-width: 7em !important;
}
.log-entry-message {
min-width: 25em !important;
} }
.log-entry-message-cell { .log-entry-message-cell {
overflow-x: hidden !important; min-width: 20em !important;
text-overflow: ellipsis !important; white-space: pre-wrap !important;
overflow-wrap: anywhere !important;
} }
.log-entry-text-nowrap {
white-space: nowrap !important;
};
`)); `));
return baseclass.extend({ return baseclass.extend({
@@ -43,7 +33,7 @@ return baseclass.extend({
}, },
makeLogArea(logdataArray) { makeLogArea(logdataArray) {
let lines = `<tr class="tr"><td class="td center log-entry-empty">${_('No entries available...')}</td></tr>`; let lines = `<tr class="tr"><td class="td center">${_('No entries available...')}</td></tr>`;
let logTable = E('table', { 'id': 'logTable', 'class': 'table' }); let logTable = E('table', { 'id': 'logTable', 'class': 'table' });
for(let level of Object.keys(this.logLevels)) { for(let level of Object.keys(this.logLevels)) {
@@ -56,27 +46,30 @@ return baseclass.extend({
if(e[4] in this.logLevels) { if(e[4] in this.logLevels) {
this.logLevelsStat[e[4]] = this.logLevelsStat[e[4]] + 1; this.logLevelsStat[e[4]] = this.logLevelsStat[e[4]] + 1;
}; };
lines.push( lines.push(
`<tr class="tr log-${e[4] || 'empty'}"><td class="td left" data-title="#">${e[0]}</td>` + `<tr class="tr log-${e[4] || 'empty'}"><td class="td left log-entry-text-nowrap" data-title="#">${e[0]}</td>` +
((e[1]) ? `<td class="td left" data-title="${_('Timestamp')}">${e[1]}</td>` : '') + ((e[1]) ? `<td class="td left log-entry-time-cell" data-title="${_('Timestamp')}">${e[1]}</td>` : '') +
((e[2]) ? `<td class="td left log-entry-host-cell" data-title="${_('Host')}">${e[2]}</td>` : '') + ((e[2]) ? `<td class="td left log-entry-host-cell" data-title="${_('Host')}">${e[2]}</td>` : '') +
((e[3]) ? `<td class="td left" data-title="${_('Facility')}">${e[3]}</td>` : '') + ((e[3]) ? `<td class="td left log-entry-text-nowrap" data-title="${_('Facility')}">${e[3]}</td>` : '') +
((e[4]) ? `<td class="td left" data-title="${_('Level')}">${e[4]}</td>` : '') + ((e[4]) ? `<td class="td left log-entry-text-nowrap" data-title="${_('Level')}">${e[4]}</td>` : '') +
((e[5]) ? `<td class="td left log-entry-message-cell" data-title="${_('Message')}">${e[5]}</td>` : '') + ((e[5]) ? `<td class="td left log-entry-message-cell" data-title="${_('Message')}">${e[5]}</td>` : '') +
'</tr>' '</tr>'
); );
}); });
lines = lines.join(''); lines = lines.join('');
logTable.append( logTable.append(
E('tr', { 'class': 'tr table-titles' }, [ E('tr', { 'class': 'tr table-titles' }, [
E('th', { 'class': 'th left log-entry-number' }, '#'), E('th', { 'class': 'th left log-entry-text-nowrap' }, '#'),
(logdataArray[0][1]) ? E('th', { 'class': 'th left log-entry-time' }, _('Timestamp')) : '', (logdataArray[0][1]) ?
(logdataArray[0][2]) ? E('th', { 'class': 'th left log-entry-host' }, _('Host')) : '', E('th', { 'class': 'th left log-entry-text-nowrap' }, _('Timestamp')) : '',
(logdataArray[0][3]) ? E('th', { 'class': 'th left log-entry-facility' }, _('Facility')) : '', (logdataArray[0][2]) ?
(logdataArray[0][4]) ? E('th', { 'class': 'th left log-entry-log-level' }, _('Level')) : '', E('th', { 'class': 'th left log-entry-text-nowrap' }, _('Host')) : '',
(logdataArray[0][5]) ? E('th', { 'class': 'th left log-entry-message' }, _('Message')) : '', (logdataArray[0][3]) ?
E('th', { 'class': 'th left log-entry-text-nowrap' }, _('Facility')) : '',
(logdataArray[0][4]) ?
E('th', { 'class': 'th left log-entry-text-nowrap' }, _('Level')) : '',
(logdataArray[0][5]) ?
E('th', { 'class': 'th left log-entry-text-nowrap' }, _('Message')) : '',
]) ])
); );
}; };
@@ -9,40 +9,44 @@ return abc.view.extend({
title : _('Ruantiblock') + ' - ' + _('Log'), title : _('Ruantiblock') + ' - ' + _('Log'),
testRegexp : new RegExp(/([0-9]{2}:){2}[0-9]{2}/), logdRegexp : new RegExp(/^([^\s]{3}\s+[^\s]{3}\s+\d{1,2}\s+\d{1,2}:\d{1,2}:\d{1,2}\s+\d{4})\s+([a-z]+)\.([a-z]+)\s+(.*)$/),
syslog_ngRegexp: new RegExp(/^([^\s]{3}\s+\d{1,2}\s+\d{1,2}:\d{1,2}:\d{1,2})\s+([^\s]+)\s+(.*)$/),
entryRegexp : null,
isLoggerChecked: false, isLoggerChecked: false,
entriesHandler : null, entriesHandler : null,
logger : null,
getLogHash : null, getLogHash : null,
// logd // logd
logdHandler(strArray, lineNum) { logdHandler(strArray, lineNum) {
let logLevel = strArray[5].split('.');
return [ return [
lineNum, // # (Number) lineNum, // # (Number)
strArray.slice(0, 5).join(' '), // Timestamp (String) strArray[1], // Timestamp (String)
null, // Host (String) null, // Host (String)
logLevel[0], // Facility (String) strArray[2], // Facility (String)
logLevel[1], // Level (String) strArray[3], // Level (String)
this.htmlEntities(strArray.slice(6).join(' ')), // Message (String) this.htmlEntities(strArray[4]) || ' ', // Message (String)
]; ];
}, },
// syslog-ng // syslog-ng
syslog_ngHandler(strArray, lineNum) { syslog_ngHandler(strArray, lineNum) {
if(!(strArray[3] in this.logHosts)) { if(!(strArray[2] in this.logHosts)) {
this.logHosts[strArray[3]] = this.makeLogHostsDropdownItem(strArray[3]); this.logHosts[strArray[2]] = this.makeLogHostsDropdownItem(strArray[2]);
}; };
return [ return [
lineNum, // # (Number) lineNum, // # (Number)
strArray.slice(0, 3).join(' '), // Timestamp (String) strArray[1], // Timestamp (String)
strArray[3], // Host (String) strArray[2], // Host (String)
null, // Facility (String) null, // Facility (String)
null, // Level (String) null, // Level (String)
this.htmlEntities(strArray.slice(4).join(' ')), // Message (String) this.htmlEntities(strArray[3]) || ' ', // Message (String)
]; ];
}, },
@@ -89,24 +93,16 @@ return abc.view.extend({
this.totalLogLines = strings.length; this.totalLogLines = strings.length;
let entriesArray = strings.map((e, i) => { let entriesArray = strings.map((e, i) => {
let strArray = e.split(/\s+/);
if(!this.isLoggerChecked) { if(!this.isLoggerChecked) {
/** if(this.logdRegexp.test(e)) {
* Checking the fourth field of a line. this.entryRegexp = this.logdRegexp;
* If it contains time then logd.
*/
if(this.testRegexp.test(strArray[3])) {
this.isFacilities = true; this.isFacilities = true;
this.isLevels = true; this.isLevels = true;
this.logHosts = {}; this.logHosts = {};
this.entriesHandler = this.logdHandler; this.entriesHandler = this.logdHandler;
} }
/** else if(this.syslog_ngRegexp.test(e)) {
* Checking the third field of a line. this.entryRegexp = this.syslog_ngRegexp;
* If it contains time then syslog-ng.
*/
else if(this.testRegexp.test(strArray[2])) {
this.isHosts = true; this.isHosts = true;
this.logFacilities = {}; this.logFacilities = {};
this.logLevels = {}; this.logLevels = {};
@@ -118,7 +114,13 @@ return abc.view.extend({
this.isLoggerChecked = true; this.isLoggerChecked = true;
}; };
return this.entriesHandler(strArray, i + 1); let strArray = e.match(this.entryRegexp);
if(strArray) {
return this.entriesHandler(strArray, i + 1);
} else {
unsupportedLog = true;
return;
};
}); });
if(unsupportedLog) { if(unsupportedLog) {
@@ -127,7 +129,6 @@ return abc.view.extend({
if(this.logSortingValue === 'desc') { if(this.logSortingValue === 'desc') {
entriesArray.reverse(); entriesArray.reverse();
}; };
return entriesArray; return entriesArray;
}; };
}, },
+1 -1
View File
@@ -1,5 +1,5 @@
# #
# (с) 2023 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt) # (с) 2024 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt)
# #
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
+1 -1
View File
@@ -1,5 +1,5 @@
# #
# (с) 2023 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt) # (с) 2024 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt)
# #
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
+1 -1
View File
@@ -1,5 +1,5 @@
# #
# (с) 2023 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt) # (с) 2024 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt)
# #
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk