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; 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) { run(labelOrValues, callback, logLevel = LogLevel.Info, filterCreator = null) {
const item = new LogItem(labelOrValues, logLevel, null, this._platform.clock); const item = new LogItem(labelOrValues, logLevel, null, this._platform.clock);
this._openItems.add(item); this._openItems.add(item);
@ -31,7 +37,7 @@ export class BaseLogger {
let filter = new LogFilter(); let filter = new LogFilter();
if (filterCreator) { if (filterCreator) {
try { try {
filter = filterCreator(filter, this); filter = filterCreator(filter, item);
} catch (err) { } catch (err) {
console.error("Error while creating log filter", err); console.error("Error while creating log filter", err);
} }

View file

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

View file

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