Hard limit for the log of 5000 entries

This commit is contained in:
Kevin Röbert 2020-06-05 21:50:03 +02:00
parent 0acd24d716
commit 762d83e46c
10 changed files with 16 additions and 16 deletions

View File

@ -272,7 +272,7 @@
"description": "Diese Zeichenfolge wird als Titel für die Schaltfläche zum Importieren auf der Einstellungsseite verwendet."
},
"setting_log_limit_label": {
"message": "Limitiert das Protokoll auf $LIMIT$ Einträge. (-1 := ∞)",
"message": "Limitiert das Protokoll auf $LIMIT$ Einträge.",
"description": "Diese Zeichenfolge wird als Name für das Protokolllimit verwendet.",
"placeholders": {
"limit": {

View File

@ -272,7 +272,7 @@
"description": "This string is used as title for the import button on the settings page."
},
"setting_log_limit_label": {
"message": "Limit the log to $LIMIT$ entries. (-1 := ∞)",
"message": "Limit the log to $LIMIT$ entries.",
"description": "This string is used as name for the log limit label.",
"placeholders": {
"limit": {

View File

@ -272,7 +272,7 @@
"description": "This string is used as title for the import button on the settings page."
},
"setting_log_limit_label": {
"message": "Limitar el tamaño del registro a $LIMIT$ eventos. (-1 := ∞)",
"message": "Limitar el tamaño del registro a $LIMIT$ eventos.",
"description": "This string is used as name for the log limit label.",
"placeholders": {
"limit": {

View File

@ -272,7 +272,7 @@
"description": "Sert à afficher la signification de la fonction sur la page qui affiche les options."
},
"setting_log_limit_label": {
"message": "Nombre déléments à enregistrer dans le journal, $LIMIT$ de -1 à linfini (-1 := ∞)",
"message": "Nombre déléments à enregistrer dans le journal, $LIMIT$ de -1 à linfini",
"description": "Sert à afficher la signification de la fonction sur la page qui affiche les options.",
"placeholders": {
"limit": {

View File

@ -272,7 +272,7 @@
"description": "This string is used as title for the import button on the settings page."
},
"setting_log_limit_label": {
"message": "Limita le voci di log a $LIMIT$. (-1 := ∞)",
"message": "Limita le voci di log a $LIMIT$.",
"description": "This string is used as name for the log limit label.",
"placeholders": {
"limit": {

View File

@ -272,7 +272,7 @@
"description": "This string is used as title for the import button on the settings page."
},
"setting_log_limit_label": {
"message": "Ограничивать журнал до $LIMIT$ записей (-1 := ∞)",
"message": "Ограничивать журнал до $LIMIT$ записей",
"description": "This string is used as name for the log limit label.",
"placeholders": {
"limit": {

View File

@ -272,7 +272,7 @@
"description": "This string is used as title for the import button on the settings page."
},
"setting_log_limit_label": {
"message": "Begränsa loggfilen till $LIMIT$ poster. (-1 := ∞)",
"message": "Begränsa loggfilen till $LIMIT$ poster.",
"description": "This string is used as name for the log limit label.",
"placeholders": {
"limit": {

View File

@ -65,7 +65,7 @@ function save()
.then(() => saveData("ruleURL", $('input[name=ruleURL]').val()))
.then(() => saveData("hashURL", $('input[name=hashURL]').val()))
.then(() => saveData("types", $('input[name=types]').val()))
.then(() => saveData("logLimit", $('input[name=logLimit]').val()))
.then(() => saveData("logLimit", Math.max(0, Math.min(5000, $('input[name=logLimit]').val()))))
.then(() => browser.runtime.sendMessage({
function: "setBadgedStatus",
params: []

View File

@ -21,6 +21,9 @@
* This script is responsible for some tools.
*/
// Max amount of log entries to prevent performance issues
const logThreshold = 5000;
/*
* To support Waterfox.
*/
@ -293,8 +296,6 @@ function handleError(error) {
/**
* Function to log all activities from ClearUrls.
* Only logging when activated.
* The log is only temporary saved in the cache and will
* permanently saved with the saveLogOnClose function.
*
* @param beforeProcessing the url before the clear process
* @param afterProcessing the url after the clear process
@ -302,11 +303,10 @@ function handleError(error) {
*/
function pushToLog(beforeProcessing, afterProcessing, rule) {
const limit = storage.logLimit;
if (storage.loggingStatus && limit !== 0) {
if (limit > 0 && !isNaN(limit)) {
while (storage.log.log.length >= limit) {
storage.log.log.shift();
}
if (storage.loggingStatus && limit !== 0 && !isNaN(limit)) {
while (storage.log.log.length >= limit
|| storage.log.log.length >= logThreshold) {
storage.log.log.shift();
}
storage.log.log.push(

View File

@ -116,7 +116,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<br />
<p>
<label id="logLimit_label"></label><br />
<input type="number" id="logLimit" value="" name="logLimit" class="form-control" min="-1">
<input type="number" id="logLimit" value="" name="logLimit" class="form-control" min="0" max="5000">
</p>
<br />
<p>