Skip to content

Conversation

@martin-fleck-at
Copy link
Contributor

@martin-fleck-at martin-fleck-at commented Apr 3, 2025

What it does

  • Ensure ConsoleLogger logs the correct log level of the message

How to test

  • See that logged messages using different log levels (info, warn, ...) actually show the correct log level next to the logged message.

Follow-ups

Changelog

  • This PR should be mentioned in the changelog
  • This PR introduces a breaking change (if yes, provide more details below for the changelog and the migration guide)

@martin-fleck-at martin-fleck-at requested a review from tortmayr April 3, 2025 12:13
return '';
}
return params.map(param => this.stringify(param)).join(',\n');
const extractedParams = params.length === 1 && Array.isArray(params[0]) ? params[0] : params;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain the reasoning behind this change?
I don't see why its necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the previous logging was a bit unexpected, see for instance our log message:

// this.logger.info(`The GLSP server is ready to accept new client requests on port: ${currentPort}`);
The GLSP server is ready to accept new client requests on port: 5007 []

```ts
// this.logger.info('This is', 'just', 'a', ['test', 'message']);
This is [
    "just",
    "a",
    [
        "test",
        "message"
    ]
]

whereas with the fix it is more as I would expect it:

// this.logger.info(`The GLSP server is ready to accept new client requests on port: ${currentPort}`);
The GLSP server is ready to accept new client requests on port: 5007 

// this.logger.info('This is', 'just', 'a', ['test', 'message']);
This is "just",
"a",
[
    "test",
    "message"
]

What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I still don't get it. Looking at the current master, I get extactly the expected behavior you described:

3:09:06 PM info -  [SocketServerLauncher] The GLSP server is ready to accept new client requests on port: 5007 
3:09:06 PM info -  [SocketServerLauncher] This is "just",
"a",
[
    "test",
    "message"
]
[GLSP-Server]:Startup completed. Accepting requests on port:5007

The current implementation:

logAdditionals(...params: any[]): string {
        if (!params || params.length === 0) {
            return '';
        }
        return params.map(param => this.stringify(param)).join(',\n');
    }

also already as a guard check for empty/undefined arrays. So
The GLSP server is ready to accept new client requests on port: 5007 [] should never happen.

But what I'm more confused by is the special handling for arrays of index length 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You probably used the WinstonLogger which does all of that already correctly! In any case, the real culprit was the missing spread when forwarding the params from the individual message calls (log, info, debug, etc.). Now it should behave more as expected. Please have another look.

@tortmayr tortmayr merged commit 867d5a7 into main Apr 3, 2025
6 checks passed
@tortmayr tortmayr deleted the issues/fix-logger branch April 3, 2025 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants