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

DidChangeConfigurationParams message overwrites initialization of root logger handler #1483

Open
scottkurz opened this issue Feb 16, 2023 · 1 comment

Comments

@scottkurz
Copy link

I'm basically running off of the 0.23.0 version..(though hacking a bit so I have a bit from main).

I'm relying on the 'log.level' sysprop to initialize the special FileHandler set up off of the root Logger in LogHelper.

However this setup is getting overwritten when a DidChangeConfigurationParams request comes into the server.
The root logger gets re-initialized, all handlers removed, and the FileHandler does not get set up correctly the 2nd time.

In the debugger I see this stack (line numbers might not align precisely because I've been hacking a bit):

LogHelper.initializeRootLogger(LanguageClient, LogsSettings) line: 71
XMLLanguageServer.updateSettings(Object, boolean) line: 179
XMLLanguageServer.updateSettings(Object) line: 160
XMLWorkspaceService.didChangeConfiguration(DidChangeConfigurationParams) line: 75

Looking at the code in:

public synchronized void updateSettings(Object initOptions) {
updateSettings(initOptions, true);
}
/**
* Update XML settings configured from the client.
*
* @param initOptions Settings the XML settings
* @param initLogs whether to initialize the log handlers
*/
private synchronized void updateSettings(Object initOptions, boolean initLogs) {
if (initOptions == null) {
return;
}
// Update client settings
Object initSettings = AllXMLSettings.getAllXMLSettings(initOptions);
XMLGeneralClientSettings xmlClientSettings = XMLGeneralClientSettings.getGeneralXMLSettings(initSettings);
if (xmlClientSettings != null) {
if (initLogs) {
// Update logs settings
LogHelper.initializeRootLogger(languageClient, xmlClientSettings.getLogs());
}

It seems that maybe the XMLLanguageServer.updateSettings() should only conditionally call the LogHelper.initializeRootLogger() routine. Maybe it should look if an initialize of the root logger has already been done, and/or if the DidChangeConfigurationParams payload contains anything log-related?

In my case the DidChangeConfigurationParams payload is this:

{"xml":{"maven":{}}}

Let me stop and make sure there's no issue with my understanding of the problem before trying to suggest a fix. Thanks.

@angelozerr
Copy link
Contributor

angelozerr commented Feb 20, 2023

I don't master this logger code, but I think it was done like this to give the capability to remove logs configured when user change setting sand it removes logs from settings. @fbricon could you help us about that please?

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

No branches or pull requests

2 participants