-
Notifications
You must be signed in to change notification settings - Fork 105
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
Conversation
sample/SampleServer/Program.cs
Outdated
.ConfigureLogging(x => x | ||
.AddSerilog() | ||
.AddLanguageServer(LogLevel.Critical) | ||
.SetMinimumLevel(LogLevel.Trace)) |
There was a problem hiding this comment.
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),
There was a problem hiding this comment.
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; | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a better way - I had to do something similar for KubeClient:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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>
There was a problem hiding this 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; | ||
} |
There was a problem hiding this comment.
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.
.ConfigureLogging(x => x | ||
.AddSerilog() | ||
.AddLanguageServer(LogLevel.Error) | ||
.SetMinimumLevel(LogLevel.Error)) |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
replaces
AddDefaultLoggingProvider()
with.AddLanguageServer()
.Allows you to pass in a
LogLevel
into.AddLanguageServer()
(default is Information)