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,core): auto flush logs after useLogger call #8738

Merged
merged 3 commits into from
Dec 16, 2021
Merged

fix(common,core): auto flush logs after useLogger call #8738

merged 3 commits into from
Dec 16, 2021

Conversation

micalevisk
Copy link
Member

@micalevisk micalevisk commented Dec 4, 2021

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

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

What is the current behavior?

Issue Number: closes #8733

I tested it locally with the following usages -- assuming that there was a call to app.useLogger:

NestFactory.createApplicationContext(AppModule)

flushes (even tho the aren't logs buffered).

NestFactory.createApplicationContext(AppModule, { bufferLogs: true })

flushes.

NestFactory.createApplicationContext(AppModule, { bufferLogs: true, autoFlushLogs: true })

flushes.

NestFactory.createApplicationContext(AppModule, { bufferLogs: true, autoFlushLogs: false })

do not flushes.

What is the new behavior?

When using NestApplicationContext app and autoFlushLogs is on, invoking useLogger method on it will flushes its logs.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

A naive attempt to address that issue without much effort. I have few concerns regarding my solution but I didn't come with anything better (nor easy to follow). Feel free to rejected it then :p

@coveralls
Copy link

coveralls commented Dec 4, 2021

Pull Request Test Coverage Report for Build a668766f-3841-414a-ad8a-9f83e671dd53

  • 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 94.08%

Totals Coverage Status
Change from base Build b0bb0a6e-71e0-4feb-a373-e0a70f8ad93b: 0.0%
Covered Lines: 5658
Relevant Lines: 6014

💛 - Coveralls

Copy link
Member

@jmcdo29 jmcdo29 left a comment

Choose a reason for hiding this comment

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

Happy to see this added in. Left a minor comment, but the functionality itself looks fine to me

packages/core/nest-application-context.ts Outdated Show resolved Hide resolved
packages/core/nest-factory.ts Outdated Show resolved Hide resolved
When using `NestApplicationContext` app and `autoFlushLogs` is on,
invoking `useLogger` method on it must flushes its logs.
@kamilmysliwiec kamilmysliwiec merged commit ffc0389 into nestjs:master Dec 16, 2021
@kamilmysliwiec
Copy link
Member

LGTM

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.

NestFactory.createApplicationContext buffer logs does not print buffered logs to custom logger
4 participants