Skip to content

Commit

Permalink
debug: add timestamp in dap traces
Browse files Browse the repository at this point in the history
The commit adds timestamps to the debug adapter traces to
get a better representation of the performance and context of the
output.

Signed-off-by: bob <[email protected]>
  • Loading branch information
DanboDuan authored Dec 2, 2021
1 parent 0be02b4 commit f97f787
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/debug/src/browser/debug-session-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,20 @@ export class DebugSessionConnection implements Disposable {
const connection = await this.connectionPromise;
const messageStr = JSON.stringify(message);
if (this.traceOutputChannel) {
this.traceOutputChannel.appendLine(`${this.sessionId.substring(0, 8)} theia -> adapter: ${messageStr}`);
const now = new Date();
const dateStr = `${now.toLocaleString(undefined, { hour12: false })}.${now.getMilliseconds()}`;
this.traceOutputChannel.appendLine(`${this.sessionId.substring(0, 8)} ${dateStr} theia -> adapter: ${JSON.stringify(message, undefined, 4)}`);
}
connection.send(messageStr);
}

protected handleMessage(data: string): void {
const message: DebugProtocol.ProtocolMessage = JSON.parse(data);
if (this.traceOutputChannel) {
this.traceOutputChannel.appendLine(`${this.sessionId.substring(0, 8)} theia <- adapter: ${data}`);
const now = new Date();
const dateStr = `${now.toLocaleString(undefined, { hour12: false })}.${now.getMilliseconds()}`;
this.traceOutputChannel.appendLine(`${this.sessionId.substring(0, 8)} ${dateStr} theia <- adapter: ${JSON.stringify(message, undefined, 4)}`);
}
const message: DebugProtocol.ProtocolMessage = JSON.parse(data);
if (message.type === 'request') {
this.handleRequest(message as DebugProtocol.Request);
} else if (message.type === 'response') {
Expand Down

0 comments on commit f97f787

Please sign in to comment.