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

fix(common): Single stdout.write() call per logging in default Logger #3350

Merged
merged 1 commit into from
Nov 15, 2019

Conversation

ulrichb
Copy link
Contributor

@ulrichb ulrichb commented Nov 7, 2019

This fixes the issue that in PM2 (at least when running in Windows) the logging lines break at the "stdout.write() border".

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[x] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior?

The default LoggerService multiple times calls process.stdout.write() per logging line. This seems to confuse the process manager PM2's logging system (the full logging message is split into 2 or more parts).

An example screenshot:
image

What is the new behavior?

I've refactored printMessage() so that it concatenates the logging string first and then calls process.stdout.write() once. Same in printStackTrace().

Note that other than this there should be no change of the behavior.

... and this fixes my issue with PM2:
image

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

This fixes the issue that in PM2 (at least when running in Windows) the logging lines break at the "stdout.write() border".
@coveralls
Copy link

Pull Request Test Coverage Report for Build 6696

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 95.311%

Totals Coverage Status
Change from base Build 6687: 0.0%
Covered Lines: 4391
Relevant Lines: 4607

💛 - Coveralls

Copy link
Member

@BrunnerLivio BrunnerLivio left a comment

Choose a reason for hiding this comment

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

LGTM

@ulrichb ulrichb changed the title fix(common): Single stdout.write() per line in default Logger fix(common): Single stdout.write() call per logging in default Logger Nov 7, 2019
@kamilmysliwiec kamilmysliwiec added this to the 6.9.1 milestone Nov 8, 2019
@kamilmysliwiec kamilmysliwiec changed the base branch from master to 6.10.0 November 15, 2019 12:11
@kamilmysliwiec kamilmysliwiec modified the milestones: 6.9.1, 6.10, 6.10.0 Nov 15, 2019
@kamilmysliwiec kamilmysliwiec merged commit 793ddc6 into nestjs:6.10.0 Nov 15, 2019
@ulrichb ulrichb deleted the SingleWriteInLogger branch November 15, 2019 12:14
@lock
Copy link

lock bot commented Feb 13, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants