ensure removing expired members from call is always logged

also return the log item from logger.log so we can ref it
This commit is contained in:
Bruno Windels 2022-10-07 10:07:10 +02:00
parent 4a36fd96e4
commit 400df6a4ff
3 changed files with 10 additions and 6 deletions

View File

@ -30,10 +30,11 @@ export class Logger implements ILogger {
this._platform = platform;
}
log(labelOrValues: LabelOrValues, logLevel: LogLevel = LogLevel.Info): void {
log(labelOrValues: LabelOrValues, logLevel: LogLevel = LogLevel.Info): ILogItem {
const item = new LogItem(labelOrValues, logLevel, this);
item.end = item.start;
this._persistItem(item, undefined, false);
return item;
}
/** Prefer `run()` or `log()` above this method; only use it if you have a long-running operation

View File

@ -68,7 +68,7 @@ export interface ILogItemCreator {
*/
export interface ILogger {
log(labelOrValues: LabelOrValues, logLevel?: LogLevel): void;
log(labelOrValues: LabelOrValues, logLevel?: LogLevel): ILogItem;
child(labelOrValues: LabelOrValues, logLevel?: LogLevel, filterCreator?: FilterCreator): ILogItem;
wrapOrRun<T>(item: ILogItem | undefined, labelOrValues: LabelOrValues, callback: LogCallback<T>, logLevel?: LogLevel, filterCreator?: FilterCreator): T;
runDetached<T>(labelOrValues: LabelOrValues, callback: LogCallback<T>, logLevel?: LogLevel, filterCreator?: FilterCreator): ILogItem;

View File

@ -104,14 +104,17 @@ export class GroupCall extends EventEmitter<{change: never}> {
confId: this.id,
emitUpdate: member => {
const memberKey = getMemberKey(member.userId, member.deviceId);
// only remove expired members from the call if we don't have a peer conn with them
// only remove expired members to whom we're not already connected
if (member.isExpired && !member.isConnected) {
const logItem = this.options.logger.log({
l: "removing expired member from call",
memberKey,
callId: this.id
})
member.logItem?.refDetached(logItem);
member.dispose();
this._members.remove(memberKey);
} else {
if (member.isExpired && member.isConnected) {
console.trace("was about to kick a connected but expired member");
}
this._members.update(memberKey, member);
}
},