mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-11-20 11:36:24 +01:00
ensure any breakage does not disrupt logging
This commit is contained in:
parent
2dd8803efc
commit
c3637def2e
@ -30,7 +30,11 @@ export class BaseLogger {
|
||||
const finishItem = () => {
|
||||
let filter = new LogFilter();
|
||||
if (filterCreator) {
|
||||
filter = filterCreator(filter, this);
|
||||
try {
|
||||
filter = filterCreator(filter, this);
|
||||
} catch (err) {
|
||||
console.error("Error while creating log filter", err);
|
||||
}
|
||||
} else {
|
||||
// if not filter is specified, filter out anything lower than the initial log level
|
||||
filter = filter.minLevel(logLevel);
|
||||
@ -41,7 +45,7 @@ export class BaseLogger {
|
||||
this._persistItem(serialized);
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn("Could not serialize log item", err);
|
||||
console.error("Could not serialize log item", err);
|
||||
}
|
||||
this._openItems.delete(item);
|
||||
};
|
||||
@ -75,7 +79,7 @@ export class BaseLogger {
|
||||
this._persistItem(serialized);
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn("Could not serialize log item", err);
|
||||
console.error("Could not serialize log item", err);
|
||||
}
|
||||
}
|
||||
this._openItems.clear();
|
||||
|
@ -72,7 +72,7 @@ export class IDBLogger extends BaseLogger {
|
||||
await txnAsPromise(txn);
|
||||
this._queuedItems.splice(0, amount);
|
||||
} catch (err) {
|
||||
console.warn("Could not flush logs", err);
|
||||
console.error("Could not flush logs", err);
|
||||
} finally {
|
||||
try {
|
||||
db.close();
|
||||
@ -113,7 +113,7 @@ export class IDBLogger extends BaseLogger {
|
||||
try {
|
||||
window.localStorage.setItem(`${this._name}_queuedItems`, JSON.stringify(items));
|
||||
} catch (e) {
|
||||
console.warn("Could not persist queued log items in localStorage, they will likely be lost", e);
|
||||
console.error("Could not persist queued log items in localStorage, they will likely be lost", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,11 @@ export class LogItem {
|
||||
|
||||
serialize(filter, depth) {
|
||||
if (this._filterCreator) {
|
||||
filter = this._filterCreator(new LogFilter(filter), this);
|
||||
try {
|
||||
filter = this._filterCreator(new LogFilter(filter), this);
|
||||
} catch (err) {
|
||||
console.error("Error creating log item", err);
|
||||
}
|
||||
}
|
||||
let children;
|
||||
if (this._children !== null) {
|
||||
|
Loading…
Reference in New Issue
Block a user