From c044d303c51fef560bd3d74ef4141ef41d97e6c0 Mon Sep 17 00:00:00 2001 From: gSpot Date: Tue, 27 Feb 2024 17:31:44 +0300 Subject: [PATCH] luci-app: updated log. --- autoinstall/current/autoinstall.sh | 2 +- luci-app-ruantiblock/Makefile | 4 +- .../resources/view/ruantiblock/log-base.js | 11 +++- .../resources/view/ruantiblock/log-widget.js | 63 +++++++++---------- .../resources/view/ruantiblock/log.js | 63 ++++++++++--------- ruantiblock-mod-lua/Makefile | 2 +- ruantiblock-mod-py/Makefile | 2 +- ruantiblock/Makefile | 2 +- 8 files changed, 74 insertions(+), 75 deletions(-) diff --git a/autoinstall/current/autoinstall.sh b/autoinstall/current/autoinstall.sh index 292ce5d..5818e46 100755 --- a/autoinstall/current/autoinstall.sh +++ b/autoinstall/current/autoinstall.sh @@ -11,7 +11,7 @@ LUCI_APP=1 OWRT_VERSION="current" RUAB_VERSION="1.4-1" 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" PKG_DIR="/tmp" diff --git a/luci-app-ruantiblock/Makefile b/luci-app-ruantiblock/Makefile index 1841003..eb9a31d 100644 --- a/luci-app-ruantiblock/Makefile +++ b/luci-app-ruantiblock/Makefile @@ -1,10 +1,10 @@ # -# (с) 2023 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt) +# (с) 2024 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt) # include $(TOPDIR)/rules.mk -PKG_VERSION:=1.4-1 +PKG_VERSION:=1.4-2 LUCI_TITLE:=LuCI support for ruantiblock LUCI_DEPENDS:=+ruantiblock LUCI_PKGARCH:=all diff --git a/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/log-base.js b/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/log-base.js index 94b4340..272932f 100644 --- a/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/log-base.js +++ b/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/log-base.js @@ -34,6 +34,11 @@ document.head.append(E('style', {'type': 'text/css'}, --app-log-debug: #5986b1; --app-log-entries-count-border: #555; } +#logWrapper { + overflow: auto !important; + width: 100%; + min-height: 20em'; +} .log-empty { } .log-emerg { @@ -137,6 +142,8 @@ log-emerg td { position: fixed; z-index: 1 !important; opacity: 0.7; + right: 1px; + top: 40vh; } .log-side-btn { position: relative; @@ -881,8 +888,7 @@ return baseclass.extend({ this.pollFuncWrapper = L.bind(this.pollFunc, this); this.logWrapper = E('div', { - 'id' : 'logWrapper', - 'style': 'width:100%; min-height:20em' + 'id': 'logWrapper', }, this.makeLogArea(this.parseLogData(logdata, this.tailValue))); this.fastTailValue = this.tailValue @@ -1045,7 +1051,6 @@ return baseclass.extend({ E('div', { 'align': 'right', 'class': 'log-side-block', - 'style': `right:1px; top:${window.innerHeight / 2 - 60}px`, }, [ this.refreshBtn, this.moreEntriesBtn, diff --git a/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/log-widget.js b/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/log-widget.js index 5dbb17a..b2cdbc1 100644 --- a/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/log-widget.js +++ b/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/log-widget.js @@ -5,34 +5,24 @@ document.head.append(E('style', {'type': 'text/css'}, ` -.log-entry-empty { +#logTable { + width: calc(100% - 4px); } -.log-entry-number { - min-width: 4em !important; -} -.log-entry-time { - min-width: 15em !important; -} -.log-entry-host { - min-width: 10em !important; +.log-entry-time-cell { + min-width: 14em !important; } .log-entry-host-cell { - word-break: break-all !important; - word-wrap: break-word !important; -} -.log-entry-log-level { - max-width: 5em !important; -} -.log-entry-facility{ - max-width: 7em !important; -} -.log-entry-message { - min-width: 25em !important; + min-width: 10em !important; + overflow-wrap: anywhere !important; } .log-entry-message-cell { - overflow-x: hidden !important; - text-overflow: ellipsis !important; + min-width: 20em !important; + white-space: pre-wrap !important; + overflow-wrap: anywhere !important; } +.log-entry-text-nowrap { + white-space: nowrap !important; +}; `)); return baseclass.extend({ @@ -43,7 +33,7 @@ return baseclass.extend({ }, makeLogArea(logdataArray) { - let lines = `${_('No entries available...')}`; + let lines = `${_('No entries available...')}`; let logTable = E('table', { 'id': 'logTable', 'class': 'table' }); for(let level of Object.keys(this.logLevels)) { @@ -56,27 +46,30 @@ return baseclass.extend({ if(e[4] in this.logLevels) { this.logLevelsStat[e[4]] = this.logLevelsStat[e[4]] + 1; }; - lines.push( - `${e[0]}` + - ((e[1]) ? `${e[1]}` : '') + + `${e[0]}` + + ((e[1]) ? `${e[1]}` : '') + ((e[2]) ? `${e[2]}` : '') + - ((e[3]) ? `${e[3]}` : '') + - ((e[4]) ? `${e[4]}` : '') + + ((e[3]) ? `${e[3]}` : '') + + ((e[4]) ? `${e[4]}` : '') + ((e[5]) ? `${e[5]}` : '') + '' ); }); lines = lines.join(''); - logTable.append( E('tr', { 'class': 'tr table-titles' }, [ - E('th', { 'class': 'th left log-entry-number' }, '#'), - (logdataArray[0][1]) ? E('th', { 'class': 'th left log-entry-time' }, _('Timestamp')) : '', - (logdataArray[0][2]) ? E('th', { 'class': 'th left log-entry-host' }, _('Host')) : '', - (logdataArray[0][3]) ? E('th', { 'class': 'th left log-entry-facility' }, _('Facility')) : '', - (logdataArray[0][4]) ? E('th', { 'class': 'th left log-entry-log-level' }, _('Level')) : '', - (logdataArray[0][5]) ? E('th', { 'class': 'th left log-entry-message' }, _('Message')) : '', + E('th', { 'class': 'th left log-entry-text-nowrap' }, '#'), + (logdataArray[0][1]) ? + E('th', { 'class': 'th left log-entry-text-nowrap' }, _('Timestamp')) : '', + (logdataArray[0][2]) ? + E('th', { 'class': 'th left log-entry-text-nowrap' }, _('Host')) : '', + (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')) : '', ]) ); }; diff --git a/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/log.js b/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/log.js index 4357990..fe610cf 100644 --- a/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/log.js +++ b/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/log.js @@ -9,40 +9,44 @@ return abc.view.extend({ 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, entriesHandler : null, + logger : null, + getLogHash : null, // logd logdHandler(strArray, lineNum) { - let logLevel = strArray[5].split('.'); return [ - lineNum, // # (Number) - strArray.slice(0, 5).join(' '), // Timestamp (String) - null, // Host (String) - logLevel[0], // Facility (String) - logLevel[1], // Level (String) - this.htmlEntities(strArray.slice(6).join(' ')), // Message (String) + lineNum, // # (Number) + strArray[1], // Timestamp (String) + null, // Host (String) + strArray[2], // Facility (String) + strArray[3], // Level (String) + this.htmlEntities(strArray[4]) || ' ', // Message (String) ]; }, // syslog-ng syslog_ngHandler(strArray, lineNum) { - if(!(strArray[3] in this.logHosts)) { - this.logHosts[strArray[3]] = this.makeLogHostsDropdownItem(strArray[3]); + if(!(strArray[2] in this.logHosts)) { + this.logHosts[strArray[2]] = this.makeLogHostsDropdownItem(strArray[2]); }; - return [ - lineNum, // # (Number) - strArray.slice(0, 3).join(' '), // Timestamp (String) - strArray[3], // Host (String) - null, // Facility (String) - null, // Level (String) - this.htmlEntities(strArray.slice(4).join(' ')), // Message (String) + lineNum, // # (Number) + strArray[1], // Timestamp (String) + strArray[2], // Host (String) + null, // Facility (String) + null, // Level (String) + this.htmlEntities(strArray[3]) || ' ', // Message (String) ]; }, @@ -89,24 +93,16 @@ return abc.view.extend({ this.totalLogLines = strings.length; let entriesArray = strings.map((e, i) => { - let strArray = e.split(/\s+/); - if(!this.isLoggerChecked) { - /** - * Checking the fourth field of a line. - * If it contains time then logd. - */ - if(this.testRegexp.test(strArray[3])) { + if(this.logdRegexp.test(e)) { + this.entryRegexp = this.logdRegexp; this.isFacilities = true; this.isLevels = true; this.logHosts = {}; this.entriesHandler = this.logdHandler; } - /** - * Checking the third field of a line. - * If it contains time then syslog-ng. - */ - else if(this.testRegexp.test(strArray[2])) { + else if(this.syslog_ngRegexp.test(e)) { + this.entryRegexp = this.syslog_ngRegexp; this.isHosts = true; this.logFacilities = {}; this.logLevels = {}; @@ -118,7 +114,13 @@ return abc.view.extend({ 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) { @@ -127,7 +129,6 @@ return abc.view.extend({ if(this.logSortingValue === 'desc') { entriesArray.reverse(); }; - return entriesArray; }; }, diff --git a/ruantiblock-mod-lua/Makefile b/ruantiblock-mod-lua/Makefile index 10fbeed..759841a 100644 --- a/ruantiblock-mod-lua/Makefile +++ b/ruantiblock-mod-lua/Makefile @@ -1,5 +1,5 @@ # -# (с) 2023 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt) +# (с) 2024 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt) # include $(TOPDIR)/rules.mk diff --git a/ruantiblock-mod-py/Makefile b/ruantiblock-mod-py/Makefile index 82f252f..4c4b1aa 100644 --- a/ruantiblock-mod-py/Makefile +++ b/ruantiblock-mod-py/Makefile @@ -1,5 +1,5 @@ # -# (с) 2023 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt) +# (с) 2024 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt) # include $(TOPDIR)/rules.mk diff --git a/ruantiblock/Makefile b/ruantiblock/Makefile index eae06e6..d5e0999 100644 --- a/ruantiblock/Makefile +++ b/ruantiblock/Makefile @@ -1,5 +1,5 @@ # -# (с) 2023 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt) +# (с) 2024 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt) # include $(TOPDIR)/rules.mk