Skip to content

feat(NODE-5820): Add async support for createStdioLogger #3972

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

Closed

Conversation

aditi-khare-mongoDB
Copy link
Contributor

@aditi-khare-mongoDB aditi-khare-mongoDB commented Jan 22, 2024

Description

This ticket is a subtask of NODE-4816 (Add error handling to logging). Its testing is contained within the other subtask (NODE-4848), and I ran those tests on this code to ensure they pass separately.

Promisify createStdioLogger so it supports async std i/o (see here to see more information on async stdio).

What is changing?

Change write signature (repeat of async write PR)
Wrap write method in createStdioLogger in promisify function

Is there new documentation needed for these changes?

After logging is released

What is the motivation for this change?

Async behavior stdio on certain environments.

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@aditi-khare-mongoDB aditi-khare-mongoDB marked this pull request as ready for review January 22, 2024 15:17
@durran durran self-assigned this Jan 23, 2024
@durran durran added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Jan 23, 2024
@@ -217,10 +217,10 @@ export function createStdioLogger(stream: {
write: NodeJS.WriteStream['write'];
}): MongoDBLogWritable {
return {
write: (log: Log): unknown => {
stream.write(inspect(log, { compact: true, breakLength: Infinity }), 'utf-8');
write: promisify((log: Log, cb: () => void): unknown => {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason for using promisify here and not just making this an async function?

Copy link
Contributor

Choose a reason for hiding this comment

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

The Node.js streams interface expects a callback, right?

@addaleax
Copy link
Contributor

I saw you requested re-review, just checking, I assume we're also adding a test for this?

@durran
Copy link
Member

durran commented Jan 23, 2024

I saw you requested re-review, just checking, I assume we're also adding a test for this?

There are tests in #3971 but I'm also confused on why this ticket was subtasked and not just included in the NODE-4848 PR as the changes are minimal and the tests are in the other PR?

@aditi-khare-mongoDB
Copy link
Contributor Author

aditi-khare-mongoDB commented Jan 23, 2024

@durran @addaleax will move functionality of this PR into NODE-4848 feat(NODE-4848): Add runtime error handling to logging #3971, per tech chat discussion - so tests are in the same code changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Primary Review In Review with primary reviewer, not yet ready for team's eyes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants