mirror of https://github.com/gorhill/uBlock.git
Discard repeating adjacent entries in the logger
This commit is contained in:
parent
c1af7a7e0d
commit
55e4cee6e8
|
@ -311,7 +311,6 @@ const µBlock = { // jshint ignore:line
|
|||
}
|
||||
this.fromTabId(tabId); // Must be called AFTER tab context management
|
||||
this.realm = '';
|
||||
this.id = details.requestId;
|
||||
this.setMethod(details.method);
|
||||
this.setURL(details.url);
|
||||
this.aliasURL = details.aliasURL || undefined;
|
||||
|
@ -373,7 +372,6 @@ const µBlock = { // jshint ignore:line
|
|||
|
||||
toLogger() {
|
||||
const details = {
|
||||
id: this.id,
|
||||
tstamp: 0,
|
||||
realm: this.realm,
|
||||
method: this.getMethodName(),
|
||||
|
|
|
@ -135,7 +135,6 @@ export const FilteringContext = class {
|
|||
}
|
||||
this.tstamp = 0;
|
||||
this.realm = '';
|
||||
this.id = undefined;
|
||||
this.method = 0;
|
||||
this.itype = NO_TYPE;
|
||||
this.stype = undefined;
|
||||
|
@ -175,7 +174,6 @@ export const FilteringContext = class {
|
|||
|
||||
fromFilteringContext(other) {
|
||||
this.realm = other.realm;
|
||||
this.id = other.id;
|
||||
this.type = other.type;
|
||||
this.method = other.method;
|
||||
this.url = other.url;
|
||||
|
|
|
@ -36,6 +36,7 @@ const logger = self.logger = { ownerId: Date.now() };
|
|||
const logDate = new Date();
|
||||
const logDateTimezoneOffset = logDate.getTimezoneOffset() * 60;
|
||||
const loggerEntries = [];
|
||||
let loggerEntryIdGenerator = 1;
|
||||
|
||||
const COLUMN_TIMESTAMP = 0;
|
||||
const COLUMN_FILTER = 1;
|
||||
|
@ -319,13 +320,11 @@ const LogEntry = function(details) {
|
|||
if ( details instanceof Object === false ) { return; }
|
||||
const receiver = LogEntry.prototype;
|
||||
for ( const prop in receiver ) {
|
||||
if (
|
||||
details.hasOwnProperty(prop) &&
|
||||
details[prop] !== receiver[prop]
|
||||
) {
|
||||
this[prop] = details[prop];
|
||||
}
|
||||
if ( details.hasOwnProperty(prop) === false ) { continue; }
|
||||
if ( details[prop] === receiver[prop] ) { continue; }
|
||||
this[prop] = details[prop];
|
||||
}
|
||||
this.id = `${loggerEntryIdGenerator++}`;
|
||||
if ( details.aliasURL !== undefined ) {
|
||||
this.aliased = true;
|
||||
}
|
||||
|
@ -346,7 +345,6 @@ LogEntry.prototype = {
|
|||
docHostname: '',
|
||||
domain: '',
|
||||
filter: undefined,
|
||||
id: '',
|
||||
method: '',
|
||||
realm: '',
|
||||
tabDomain: '',
|
||||
|
@ -1627,9 +1625,10 @@ dom.on(document, 'keydown', ev => {
|
|||
const aliasURLFromID = function(id) {
|
||||
if ( id === '' ) { return ''; }
|
||||
for ( const entry of loggerEntries ) {
|
||||
if ( entry.id !== id || entry.aliased ) { continue; }
|
||||
const fields = entry.textContent.split('\x1F');
|
||||
return fields[COLUMN_URL] || '';
|
||||
if ( entry.id !== id ) { continue; }
|
||||
const match = /\baliasURL=([^\x1F]+)/.exec(entry.textContent);
|
||||
if ( match === null ) { return ''; }
|
||||
return match[1];
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
|
|
@ -30,7 +30,6 @@ import { broadcast, broadcastToAll } from './broadcast.js';
|
|||
let buffer = null;
|
||||
let lastReadTime = 0;
|
||||
let writePtr = 0;
|
||||
let lastBoxedEntry = '';
|
||||
|
||||
// After 30 seconds without being read, the logger buffer will be considered
|
||||
// unused, and thus disabled.
|
||||
|
@ -44,7 +43,6 @@ const janitorTimer = vAPI.defer.create(( ) => {
|
|||
logger.enabled = false;
|
||||
buffer = null;
|
||||
writePtr = 0;
|
||||
lastBoxedEntry = '';
|
||||
logger.ownerId = undefined;
|
||||
broadcastToAll({ what: 'loggerDisabled' });
|
||||
});
|
||||
|
@ -55,6 +53,7 @@ const boxEntry = details => {
|
|||
};
|
||||
|
||||
const pushOne = box => {
|
||||
if ( writePtr !== 0 && box === buffer[writePtr-1] ) { return; }
|
||||
if ( writePtr === buffer.length ) {
|
||||
buffer.push(box);
|
||||
} else {
|
||||
|
@ -68,12 +67,7 @@ const logger = {
|
|||
ownerId: undefined,
|
||||
writeOne(details) {
|
||||
if ( buffer === null ) { return; }
|
||||
const box = boxEntry(details);
|
||||
if ( box === lastBoxedEntry ) { return; }
|
||||
if ( lastBoxedEntry !== '' ) {
|
||||
pushOne(lastBoxedEntry);
|
||||
}
|
||||
lastBoxedEntry = box;
|
||||
pushOne(boxEntry(details));
|
||||
},
|
||||
readAll(ownerId) {
|
||||
this.ownerId = ownerId;
|
||||
|
@ -83,11 +77,8 @@ const logger = {
|
|||
janitorTimer.on(logBufferObsoleteAfter);
|
||||
broadcast({ what: 'loggerEnabled' });
|
||||
}
|
||||
if ( lastBoxedEntry !== '' ) {
|
||||
pushOne(lastBoxedEntry);
|
||||
lastBoxedEntry = '';
|
||||
}
|
||||
const out = buffer.slice(0, writePtr);
|
||||
buffer.fill('', 0, writePtr);
|
||||
writePtr = 0;
|
||||
lastReadTime = Date.now();
|
||||
return out;
|
||||
|
|
Loading…
Reference in New Issue