Use undefined in LogItem.serialize

This commit is contained in:
RMidhunSuresh 2021-11-15 19:32:16 +05:30
parent ba5f2032ba
commit fe69f84c85
3 changed files with 6 additions and 6 deletions

View file

@ -118,7 +118,7 @@ export class IDBLogger extends BaseLogger {
}
_persistItem(logItem: ILogItem, filter: LogFilter, forced: boolean): void {
const serializedItem = logItem.serialize(filter, null, forced);
const serializedItem = logItem.serialize(filter, undefined, forced);
this._queuedItems.push({
json: JSON.stringify(serializedItem)
});

View file

@ -53,7 +53,7 @@ export interface ILogItem {
catch(err: Error): Error;
finish(): void;
child(labelOrValues: LabelOrValues, logLevel?: LogLevel, filterCreator?: FilterCreator): ILogItem;
serialize(filter: LogFilter, parentStartTime: number | null, forced: boolean): ISerializedItem | null;
serialize(filter: LogFilter, parentStartTime: number | undefined, forced: boolean): ISerializedItem | undefined;
}
export type LogItemValues = {
@ -171,7 +171,7 @@ export class LogItem implements ILogItem {
}
// todo: null or undefined here?
serialize(filter: LogFilter, parentStartTime: number | null = null, forced: boolean): ISerializedItem | null {
serialize(filter: LogFilter, parentStartTime: number | undefined, forced: boolean): ISerializedItem | undefined {
if (this._filterCreator) {
try {
filter = this._filterCreator(new LogFilter(filter), this);
@ -193,12 +193,12 @@ export class LogItem implements ILogItem {
}, null);
}
if (filter && !filter.filter(this, children)) {
return null;
return;
}
// in (v)alues, (l)abel and (t)ype are also reserved.
const item: ISerializedItem = {
// (s)tart
s: parentStartTime === null ? this.start : this.start - parentStartTime,
s: parentStartTime? this.start - parentStartTime : this.start,
// (d)uration
d: this.duration,
// (v)alues

View file

@ -102,7 +102,7 @@ export class NullLogItem implements ILogItem {
finish(): void {}
serialize() {
return null;
return undefined;
}
}