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

@@ -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(