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

Register the LanguageServerLogger only once #2473

Merged

Conversation

dibarbet
Copy link
Contributor

@dibarbet dibarbet commented Nov 8, 2022

Fixes bug where logs were duplicated when using the LSP version. Logged in dotnet/vscode-csharp#5429

image

@dibarbet dibarbet requested a review from 333fred November 8, 2022 02:10
@@ -62,7 +62,7 @@ public class LanguageServerHost : IDisposable
.WithInput(input)
.WithOutput(output)
// initializeParams from the client won't be arriving yet, configure with app loglevel
.ConfigureLogging(GetLogBuilderAction(configureLogging, application.LogLevel))
.ConfigureLogging(AddLanguageProtocolLogging(application.LogLevel))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

previously there were two calls to GetLogBuilderAction, one here and one when building the composition (after initialize). Both calls registered the lsp logger and so we got double logs.

I modified this to register the LSP logger initially (with default level) and then configure it on composition building (after initialize).

@dibarbet dibarbet force-pushed the register_languageserverlogger_once branch from b058805 to 3c7c9cc Compare November 8, 2022 02:31
Copy link
Contributor

@333fred 333fred left a comment

Choose a reason for hiding this comment

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

LGTM (commit 1), with a couple of formatting nits.

private static Action<ILoggingBuilder> GetLogBuilderAction(Action<ILoggingBuilder> configureLogging, LogLevel loglevel) => builder =>
private static Action<ILoggingBuilder> AddLanguageProtocolLogging(LogLevel loglevel) => builder => builder.AddLanguageProtocolLogging().SetMinimumLevel(loglevel);

private static Action<ILoggingBuilder> ConfigureLogging(Action<ILoggingBuilder> configureLogging, LogLevel loglevel) => builder =>
{
configureLogging?.Invoke(builder);
builder
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: consider joining these lines.

@@ -178,11 +178,12 @@ private static LogLevel GetLogLevel(InitializeTrace initializeTrace)
}
}

private static Action<ILoggingBuilder> GetLogBuilderAction(Action<ILoggingBuilder> configureLogging, LogLevel loglevel) => builder =>
private static Action<ILoggingBuilder> AddLanguageProtocolLogging(LogLevel loglevel) => builder => builder.AddLanguageProtocolLogging().SetMinimumLevel(loglevel);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: consider wrapping this line.

@dibarbet dibarbet merged commit e760a67 into OmniSharp:master Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants