Skip to content

Adds ILoggingBuilder extension for LanguageServer logging. #187

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

Merged
merged 2 commits into from
Oct 27, 2019

Conversation

bjorkstromm
Copy link
Member

@bjorkstromm bjorkstromm commented Oct 14, 2019

replaces AddDefaultLoggingProvider() with .AddLanguageServer().

Allows you to pass in a LogLevel into .AddLanguageServer() (default is Information)

.ConfigureLogging(x => x
.AddSerilog()
.AddLanguageServer(LogLevel.Critical)
.SetMinimumLevel(LogLevel.Trace))
Copy link
Member Author

Choose a reason for hiding this comment

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

I'd like to avoid having this, but truth is that MEL adds a default filter which works on the factory level, so we won't get our logs to LSP logger if they are < Information (which is default),

Copy link
Collaborator

Choose a reason for hiding this comment

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

As long as it's configured by the consumer (read: Host process) I think that's fine.

if (loggerSettings?.MinimumLogLevel >= LogLevel.Information)
{
loggerSettings.MinimumLogLevel = LogLevel.Trace;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Best would be if we'd also here could notify IOptionsMonitor<LoggerFilterOptions> that it has changed. Without a configuration file, we'd probably have to do something like this. https://stackoverflow.com/a/53077453

Copy link
Member

Choose a reason for hiding this comment

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

We should probably look at a configuration integration. My thought is something like interface ILspConfiguration : IConfiguration and then populate that some defaults, like the logging state, but also wrap up the configuration handlers so that they surface their data through it, along with the refresh tokens.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I solved it by registering an own IOptionsMonitor<LoggerFilterOptions>

Copy link
Member

@david-driscoll david-driscoll left a comment

Choose a reason for hiding this comment

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

LGTM

if (loggerSettings?.MinimumLogLevel >= LogLevel.Information)
{
loggerSettings.MinimumLogLevel = LogLevel.Trace;
}
Copy link
Member

Choose a reason for hiding this comment

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

We should probably look at a configuration integration. My thought is something like interface ILspConfiguration : IConfiguration and then populate that some defaults, like the logging state, but also wrap up the configuration handlers so that they surface their data through it, along with the refresh tokens.

@bjorkstromm bjorkstromm marked this pull request as ready for review October 19, 2019 22:01
.ConfigureLogging(x => x
.AddSerilog()
.AddLanguageServer(LogLevel.Error)
.SetMinimumLevel(LogLevel.Error))
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need to pass in the LogLevel for both the AddLanguageServer and SetMinimumLevel?

Copy link
Member Author

Choose a reason for hiding this comment

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

You don't need to. It's an option. One is global, the other one is just for LSP logging.

Copy link
Collaborator

@TylerLeonhardt TylerLeonhardt Oct 24, 2019

Choose a reason for hiding this comment

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

@mholo65 I gave this a go:

.AddSerilog()
.AddLanguageServer()
.SetMinimumLevel(LogLevel.Trace)

and the LSP side was only giving Information and Error but my file was giving me everything.

@david-driscoll david-driscoll merged commit e3ab388 into master Oct 27, 2019
@david-driscoll david-driscoll deleted the feature/enchance-logging branch October 27, 2019 17:30
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.

4 participants