forked from mystiq/hydrogen-web
better error handling if something goes wrong serializing log items
This commit is contained in:
parent
338f628627
commit
2dd8803efc
1 changed files with 14 additions and 6 deletions
|
@ -35,10 +35,14 @@ export class BaseLogger {
|
|||
// if not filter is specified, filter out anything lower than the initial log level
|
||||
filter = filter.minLevel(logLevel);
|
||||
}
|
||||
try {
|
||||
const serialized = item.serialize(filter, 0);
|
||||
if (serialized) {
|
||||
this._persistItem(serialized);
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn("Could not serialize log item", err);
|
||||
}
|
||||
this._openItems.delete(item);
|
||||
};
|
||||
|
||||
|
@ -65,10 +69,14 @@ export class BaseLogger {
|
|||
_finishOpenItems() {
|
||||
for (const openItem of this._openItems) {
|
||||
openItem.finish();
|
||||
try {
|
||||
const serialized = openItem.serialize(this._baseLogLevel);
|
||||
if (serialized) {
|
||||
this._persistItem(serialized);
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn("Could not serialize log item", err);
|
||||
}
|
||||
}
|
||||
this._openItems.clear();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue