-
Notifications
You must be signed in to change notification settings - Fork 735
test(logger): test logger does not format objects as expected #6083
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
| }) | ||
| }) | ||
|
|
||
| it('assigns schemas to the yaml extension', async function () { |
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.
when passing some objects through util.format I noticed it set a property _formatted (perhaps as a cache?), so without these changes the test fails. Also avoids some small code dupe.
0731ea7 to
e9ff8a3
Compare
| * In-memory Logger implementation suitable for use by tests. | ||
| */ | ||
| export class TestLogger implements Logger { | ||
| export class TestLogger extends BaseLogger { |
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.
Nice, was just thinking about this!
justinmk3
left a comment
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.
Great!
Problem
The test logger does not format additional arguements into the logs in the same way as ToolkitLogger.
Ex.
getLogger().debug('here is the obj: %O', obj)will produce twoLogEntriesone with"here is the obj: %O"and one with the object itself.This is problematic because it causes confusion (see: #5895 (comment)) and it also can cause
assertLogsContainto throw an error since there is now a non-string/error entry in the log entry list (see:aws-toolkit-vscode/packages/core/src/test/globalSetup.test.ts
Lines 171 to 185 in 338ea67
Solution
BaseLoggerto minimize implementation dupe.testLogger.util.format: https://github.com/nodejs/node/blob/3178a762d6a2b1a37b74f02266eea0f3d86603be/lib/internal/util/inspect.js#L2191-L2315License: I confirm that my contribution is made under the terms of the Apache 2.0 license.