log pagehide event

This commit is contained in:
Bruno Windels 2021-02-18 19:46:40 +01:00
parent cfc17ad176
commit f2f9162b85
3 changed files with 9 additions and 2 deletions

View File

@ -23,6 +23,12 @@ export class BaseLogger {
this._platform = platform;
}
log(labelOrValues, logLevel = LogLevel.Info) {
const item = new LogItem(labelOrValues, logLevel, null, this._platform.clock);
item._end = item._start;
this._persistItem(item.serialize(null));
}
run(labelOrValues, callback, logLevel = LogLevel.Info, filterCreator = null) {
const item = new LogItem(labelOrValues, logLevel, null, this._platform.clock);
this._openItems.add(item);
@ -31,7 +37,7 @@ export class BaseLogger {
let filter = new LogFilter();
if (filterCreator) {
try {
filter = filterCreator(filter, this);
filter = filterCreator(filter, item);
} catch (err) {
console.error("Error while creating log filter", err);
}

View File

@ -82,6 +82,7 @@ export class IDBLogger extends BaseLogger {
_finishAllAndFlush() {
this._finishOpenItems();
this.log({l: "pagehide, closing logs", t: "navigation"});
this._persistQueuedItems(this._queuedItems);
}

View File

@ -86,7 +86,7 @@ export class LogItem {
return array;
}, null);
}
if (!filter.filter(this, children)) {
if (filter && !filter.filter(this, children)) {
return null;
}
// in (v)alues, (l)abel and (t)ype are also reserved.