mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-22 02:12:44 +01:00
Throttle down repeated scriptlet logging information
Related feedback https://github.com/uBlockOrigin/uBlock-issues/issues/3378#issuecomment-2356422784
This commit is contained in:
parent
acffae6a21
commit
e8f6f3ddff
@ -176,9 +176,18 @@ function safeSelf() {
|
|||||||
const bc = new self.BroadcastChannel(scriptletGlobals.bcSecret);
|
const bc = new self.BroadcastChannel(scriptletGlobals.bcSecret);
|
||||||
let bcBuffer = [];
|
let bcBuffer = [];
|
||||||
safe.logLevel = scriptletGlobals.logLevel || 1;
|
safe.logLevel = scriptletGlobals.logLevel || 1;
|
||||||
|
let lastLogType = '';
|
||||||
|
let lastLogText = '';
|
||||||
|
let lastLogTime = 0;
|
||||||
safe.sendToLogger = (type, ...args) => {
|
safe.sendToLogger = (type, ...args) => {
|
||||||
if ( args.length === 0 ) { return; }
|
if ( args.length === 0 ) { return; }
|
||||||
const text = `[${document.location.hostname || document.location.href}]${args.join(' ')}`;
|
const text = `[${document.location.hostname || document.location.href}]${args.join(' ')}`;
|
||||||
|
if ( text === lastLogText && type === lastLogType ) {
|
||||||
|
if ( (Date.now() - lastLogTime) < 300000 ) { return; }
|
||||||
|
}
|
||||||
|
lastLogType = type;
|
||||||
|
lastLogText = text;
|
||||||
|
lastLogTime = Date.now();
|
||||||
if ( bcBuffer === undefined ) {
|
if ( bcBuffer === undefined ) {
|
||||||
return bc.postMessage({ what: 'messageToLogger', type, text });
|
return bc.postMessage({ what: 'messageToLogger', type, text });
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user