Hard limit for the log of 5000 entries
This commit is contained in:
parent
0acd24d716
commit
762d83e46c
|
@ -272,7 +272,7 @@
|
||||||
"description": "Diese Zeichenfolge wird als Titel für die Schaltfläche zum Importieren auf der Einstellungsseite verwendet."
|
"description": "Diese Zeichenfolge wird als Titel für die Schaltfläche zum Importieren auf der Einstellungsseite verwendet."
|
||||||
},
|
},
|
||||||
"setting_log_limit_label": {
|
"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.",
|
"description": "Diese Zeichenfolge wird als Name für das Protokolllimit verwendet.",
|
||||||
"placeholders": {
|
"placeholders": {
|
||||||
"limit": {
|
"limit": {
|
||||||
|
|
|
@ -272,7 +272,7 @@
|
||||||
"description": "This string is used as title for the import button on the settings page."
|
"description": "This string is used as title for the import button on the settings page."
|
||||||
},
|
},
|
||||||
"setting_log_limit_label": {
|
"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.",
|
"description": "This string is used as name for the log limit label.",
|
||||||
"placeholders": {
|
"placeholders": {
|
||||||
"limit": {
|
"limit": {
|
||||||
|
|
|
@ -272,7 +272,7 @@
|
||||||
"description": "This string is used as title for the import button on the settings page."
|
"description": "This string is used as title for the import button on the settings page."
|
||||||
},
|
},
|
||||||
"setting_log_limit_label": {
|
"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.",
|
"description": "This string is used as name for the log limit label.",
|
||||||
"placeholders": {
|
"placeholders": {
|
||||||
"limit": {
|
"limit": {
|
||||||
|
|
|
@ -272,7 +272,7 @@
|
||||||
"description": "Sert à afficher la signification de la fonction sur la page qui affiche les options."
|
"description": "Sert à afficher la signification de la fonction sur la page qui affiche les options."
|
||||||
},
|
},
|
||||||
"setting_log_limit_label": {
|
"setting_log_limit_label": {
|
||||||
"message": "Nombre d’éléments à enregistrer dans le journal, $LIMIT$ de -1 à l’infini (-1 := ∞)",
|
"message": "Nombre d’éléments à enregistrer dans le journal, $LIMIT$ de -1 à l’infini",
|
||||||
"description": "Sert à afficher la signification de la fonction sur la page qui affiche les options.",
|
"description": "Sert à afficher la signification de la fonction sur la page qui affiche les options.",
|
||||||
"placeholders": {
|
"placeholders": {
|
||||||
"limit": {
|
"limit": {
|
||||||
|
|
|
@ -272,7 +272,7 @@
|
||||||
"description": "This string is used as title for the import button on the settings page."
|
"description": "This string is used as title for the import button on the settings page."
|
||||||
},
|
},
|
||||||
"setting_log_limit_label": {
|
"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.",
|
"description": "This string is used as name for the log limit label.",
|
||||||
"placeholders": {
|
"placeholders": {
|
||||||
"limit": {
|
"limit": {
|
||||||
|
|
|
@ -272,7 +272,7 @@
|
||||||
"description": "This string is used as title for the import button on the settings page."
|
"description": "This string is used as title for the import button on the settings page."
|
||||||
},
|
},
|
||||||
"setting_log_limit_label": {
|
"setting_log_limit_label": {
|
||||||
"message": "Ограничивать журнал до $LIMIT$ записей (-1 := ∞)",
|
"message": "Ограничивать журнал до $LIMIT$ записей",
|
||||||
"description": "This string is used as name for the log limit label.",
|
"description": "This string is used as name for the log limit label.",
|
||||||
"placeholders": {
|
"placeholders": {
|
||||||
"limit": {
|
"limit": {
|
||||||
|
|
|
@ -272,7 +272,7 @@
|
||||||
"description": "This string is used as title for the import button on the settings page."
|
"description": "This string is used as title for the import button on the settings page."
|
||||||
},
|
},
|
||||||
"setting_log_limit_label": {
|
"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.",
|
"description": "This string is used as name for the log limit label.",
|
||||||
"placeholders": {
|
"placeholders": {
|
||||||
"limit": {
|
"limit": {
|
||||||
|
|
|
@ -65,7 +65,7 @@ function save()
|
||||||
.then(() => saveData("ruleURL", $('input[name=ruleURL]').val()))
|
.then(() => saveData("ruleURL", $('input[name=ruleURL]').val()))
|
||||||
.then(() => saveData("hashURL", $('input[name=hashURL]').val()))
|
.then(() => saveData("hashURL", $('input[name=hashURL]').val()))
|
||||||
.then(() => saveData("types", $('input[name=types]').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({
|
.then(() => browser.runtime.sendMessage({
|
||||||
function: "setBadgedStatus",
|
function: "setBadgedStatus",
|
||||||
params: []
|
params: []
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
* This script is responsible for some tools.
|
* This script is responsible for some tools.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Max amount of log entries to prevent performance issues
|
||||||
|
const logThreshold = 5000;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* To support Waterfox.
|
* To support Waterfox.
|
||||||
*/
|
*/
|
||||||
|
@ -293,8 +296,6 @@ function handleError(error) {
|
||||||
/**
|
/**
|
||||||
* Function to log all activities from ClearUrls.
|
* Function to log all activities from ClearUrls.
|
||||||
* Only logging when activated.
|
* 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 beforeProcessing the url before the clear process
|
||||||
* @param afterProcessing the url after the clear process
|
* @param afterProcessing the url after the clear process
|
||||||
|
@ -302,11 +303,10 @@ function handleError(error) {
|
||||||
*/
|
*/
|
||||||
function pushToLog(beforeProcessing, afterProcessing, rule) {
|
function pushToLog(beforeProcessing, afterProcessing, rule) {
|
||||||
const limit = storage.logLimit;
|
const limit = storage.logLimit;
|
||||||
if (storage.loggingStatus && limit !== 0) {
|
if (storage.loggingStatus && limit !== 0 && !isNaN(limit)) {
|
||||||
if (limit > 0 && !isNaN(limit)) {
|
while (storage.log.log.length >= limit
|
||||||
while (storage.log.log.length >= limit) {
|
|| storage.log.log.length >= logThreshold) {
|
||||||
storage.log.log.shift();
|
storage.log.log.shift();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.log.log.push(
|
storage.log.log.push(
|
||||||
|
|
|
@ -116,7 +116,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
<br />
|
<br />
|
||||||
<p>
|
<p>
|
||||||
<label id="logLimit_label"></label><br />
|
<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>
|
</p>
|
||||||
<br />
|
<br />
|
||||||
<p>
|
<p>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user