mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-22 19:14:52 +01:00
Merge pull request #1080 from vector-im/fix-call-issues
Fix large log files generated when calls are used
This commit is contained in:
commit
e5d5f468d5
@ -28,6 +28,7 @@ export class LogItem implements ILogItem {
|
|||||||
protected _logger: Logger;
|
protected _logger: Logger;
|
||||||
private _filterCreator?: FilterCreator;
|
private _filterCreator?: FilterCreator;
|
||||||
private _children?: Array<LogItem>;
|
private _children?: Array<LogItem>;
|
||||||
|
private _discard: boolean = false;
|
||||||
|
|
||||||
constructor(labelOrValues: LabelOrValues, logLevel: LogLevel, logger: Logger, filterCreator?: FilterCreator) {
|
constructor(labelOrValues: LabelOrValues, logLevel: LogLevel, logger: Logger, filterCreator?: FilterCreator) {
|
||||||
this._logger = logger;
|
this._logger = logger;
|
||||||
@ -38,6 +39,13 @@ export class LogItem implements ILogItem {
|
|||||||
this._filterCreator = filterCreator;
|
this._filterCreator = filterCreator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prevents this log item from being present in the exported output.
|
||||||
|
*/
|
||||||
|
discard(): void {
|
||||||
|
this._discard = true;
|
||||||
|
}
|
||||||
|
|
||||||
/** start a new root log item and run it detached mode, see Logger.runDetached */
|
/** start a new root log item and run it detached mode, see Logger.runDetached */
|
||||||
runDetached(labelOrValues: LabelOrValues, callback: LogCallback<unknown>, logLevel?: LogLevel, filterCreator?: FilterCreator): ILogItem {
|
runDetached(labelOrValues: LabelOrValues, callback: LogCallback<unknown>, logLevel?: LogLevel, filterCreator?: FilterCreator): ILogItem {
|
||||||
return this._logger.runDetached(labelOrValues, callback, logLevel, filterCreator);
|
return this._logger.runDetached(labelOrValues, callback, logLevel, filterCreator);
|
||||||
@ -119,6 +127,9 @@ export class LogItem implements ILogItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
serialize(filter: LogFilter, parentStartTime: number | undefined, forced: boolean): ISerializedItem | undefined {
|
serialize(filter: LogFilter, parentStartTime: number | undefined, forced: boolean): ISerializedItem | undefined {
|
||||||
|
if (this._discard) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this._filterCreator) {
|
if (this._filterCreator) {
|
||||||
try {
|
try {
|
||||||
filter = this._filterCreator(new LogFilter(filter), this);
|
filter = this._filterCreator(new LogFilter(filter), this);
|
||||||
|
@ -74,6 +74,10 @@ export class NullLogItem implements ILogItem {
|
|||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
discard(): void {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
|
|
||||||
wrap<T>(_: LabelOrValues, callback: LogCallback<T>): T {
|
wrap<T>(_: LabelOrValues, callback: LogCallback<T>): T {
|
||||||
return this.run(callback);
|
return this.run(callback);
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ export interface ILogItem {
|
|||||||
finish(): void;
|
finish(): void;
|
||||||
forceFinish(): void;
|
forceFinish(): void;
|
||||||
child(labelOrValues: LabelOrValues, logLevel?: LogLevel, filterCreator?: FilterCreator): ILogItem;
|
child(labelOrValues: LabelOrValues, logLevel?: LogLevel, filterCreator?: FilterCreator): ILogItem;
|
||||||
|
discard(): void;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
extend both ILogger and ILogItem from this interface, but need to rename ILogger.run => wrap then. Or both to `span`?
|
extend both ILogger and ILogItem from this interface, but need to rename ILogger.run => wrap then. Or both to `span`?
|
||||||
|
@ -78,6 +78,9 @@ export class Session {
|
|||||||
this._roomsBeingCreated = new ObservableMap();
|
this._roomsBeingCreated = new ObservableMap();
|
||||||
this._user = new User(sessionInfo.userId);
|
this._user = new User(sessionInfo.userId);
|
||||||
this._roomStateHandler = new RoomStateHandlerSet();
|
this._roomStateHandler = new RoomStateHandlerSet();
|
||||||
|
if (features.calls) {
|
||||||
|
this._setupCallHandler();
|
||||||
|
}
|
||||||
this._deviceMessageHandler = new DeviceMessageHandler({storage, callHandler: this._callHandler});
|
this._deviceMessageHandler = new DeviceMessageHandler({storage, callHandler: this._callHandler});
|
||||||
this._olm = olm;
|
this._olm = olm;
|
||||||
this._olmUtil = null;
|
this._olmUtil = null;
|
||||||
@ -106,10 +109,6 @@ export class Session {
|
|||||||
this._createRoomEncryption = this._createRoomEncryption.bind(this);
|
this._createRoomEncryption = this._createRoomEncryption.bind(this);
|
||||||
this._forgetArchivedRoom = this._forgetArchivedRoom.bind(this);
|
this._forgetArchivedRoom = this._forgetArchivedRoom.bind(this);
|
||||||
this.needsKeyBackup = new ObservableValue(false);
|
this.needsKeyBackup = new ObservableValue(false);
|
||||||
|
|
||||||
if (features.calls) {
|
|
||||||
this._setupCallHandler();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get fingerprintKey() {
|
get fingerprintKey() {
|
||||||
|
@ -424,6 +424,11 @@ export class GroupCall extends EventEmitter<{change: never}> {
|
|||||||
member.dispose();
|
member.dispose();
|
||||||
this._members.remove(memberKey);
|
this._members.remove(memberKey);
|
||||||
log.set("removed", true);
|
log.set("removed", true);
|
||||||
|
} else {
|
||||||
|
// We don't want to pollute the logs with all the expired members.
|
||||||
|
// This can be an issue for long lived calls that have had a large number
|
||||||
|
// of users join and leave at some point in time.
|
||||||
|
log.discard();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user