Skip to content
New issue

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

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

Already on GitHub? # to your account

Enable connection message logging in debug mode #147

Merged
merged 2 commits into from
Apr 11, 2024

Conversation

charlieegan3
Copy link
Collaborator

This is enabled when developing the extension. MessageStrategy is a handy place to hook into with logs and a debugger when inspecting the messages between the client and server.

I thought this was a sensible default.

This is enabled when developing the extension. MessageStrategy is a
handy place to hook into with logs and a debugger when inspecting the
messages between the client and server.

I thought this was a sensible default.

Signed-off-by: Charlie Egan <charlie@styra.com>
@@ -143,6 +157,9 @@ export function activateRegal(_context: ExtensionContext) {
outputChannel: outChan,
traceOutputChannel: outChan,
revealOutputChannelOn: 0,
connectionOptions: {
messageStrategy: new debuggableMessageStrategy,
Copy link
Collaborator Author

@charlieegan3 charlieegan3 Apr 10, 2024

Choose a reason for hiding this comment

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

I was mainly keen to have something here so that we had it as bookmark so to speak. As it took me some time work out that this was an option and did what I thought it did.

Copy link
Member

@anderseknert anderseknert left a comment

Choose a reason for hiding this comment

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

Awesome, thanks!

// we can log the messages to the console for debugging purposes.
if (process.env.VSCODE_DEBUG_MODE === 'true') {
const messageData = JSON.parse(JSON.stringify(message));
const method = messageData.method !== undefined ? messageData.method : 'response';
Copy link
Member

Choose a reason for hiding this comment

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

const method = messageData.method || 'response'; or does that not work in typescript? :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ahh, that does work. I'll use that.

Signed-off-by: Charlie Egan <charlie@styra.com>
@charlieegan3 charlieegan3 merged commit 903bd6d into master Apr 11, 2024
4 checks passed
@anderseknert anderseknert deleted the debug-message-logging branch April 15, 2024 11:07
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants