Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helper to help components spit out debug logs #2349

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@ export enum ClientEvent {
DeleteRoom = "deleteRoom",
SyncUnexpectedError = "sync.unexpectedError",
ClientWellKnown = "WellKnown.client",
DumpDebugLogs = "logging.dumpDebugLogs",
}

type RoomEvents = RoomEvent.Name
Expand Down Expand Up @@ -852,6 +853,7 @@ export type ClientEventHandlerMap = {
[ClientEvent.DeleteRoom]: (roomId: string) => void;
[ClientEvent.SyncUnexpectedError]: (error: Error) => void;
[ClientEvent.ClientWellKnown]: (data: IClientWellKnown) => void;
[ClientEvent.DumpDebugLogs]: () => void;
} & RoomEventHandlerMap
& RoomStateEventHandlerMap
& CryptoEventHandlerMap
Expand Down Expand Up @@ -8961,6 +8963,11 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
},
);
}

public dumpDebugLogs() {
logger.debug('matrix-js-sdk: dumping extra debug logs to the console');
this.emit(ClientEvent.DumpDebugLogs);
}
Comment on lines +8967 to +8970
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using logs is a really bad mechanism given that it relies on consumers monkey-patching console which we don't say anywhere in the generated docs to do

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't have to live in matrix-js-sdk. What event emitter pattern can we use exclusively in matrix-react-sdk? This point is tracked by matrix-org/matrix-react-sdk#8502 (comment)

}

/**
Expand Down