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

feat(core): add option to disable logs on LazyModuleLoader#load #9836

Merged
merged 3 commits into from Jul 28, 2022

Conversation

micalevisk
Copy link
Member

@micalevisk micalevisk commented Jun 26, 2022

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 #9107

What is the new behavior?

const moduleRef = await this.lazyModuleLoader.load(() => LazyModule, { logger: false });

const moduleRef = await this.lazyModuleLoader.load(() => LazyModule); // logs enabled

I choose the name logger so we could enhance this feature later on without introducing breaking changes on that signature

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@coveralls
Copy link

coveralls commented Jun 26, 2022

Pull Request Test Coverage Report for Build f23ec8df-fadf-44d6-91ab-64f8a00faede

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

Totals Coverage Status
Change from base Build 262c4fc1-af48-4f76-bf4a-4cc857665279: 0.0%
Covered Lines: 0
Relevant Lines: 0

💛 - Coveralls

Copy link
Contributor

@Tony133 Tony133 left a comment

Choose a reason for hiding this comment

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

Now it is much better, so the principle of "Single Responsibility" is respected, but now I have another doubt that it "torments" me it is better to leave it inside the injector folder or move it to where the Logger and the LoggerService are because the SilentLogger class extends Logger? 😄 maybe it is better to move it inside the common folder? 🤔

Comment on lines +1 to +12
import { Logger } from '@nestjs/common';

// eslint-disable-next-line @typescript-eslint/no-empty-function
const noop = () => {};
export class SilentLogger extends Logger {
log = noop;
error = noop;
warn = noop;
debug = noop;
verbose = noop;
setLogLevels = noop;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Now it is much better, so the principle of "Single Responsibility" is respected, but now I have another doubt that it "torments" me it is better to leave it inside the injector folder or move it to where the Logger and the LoggerService are because the SilentLogger class extends Logger? 😄 maybe it is better to move it inside the common folder? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm unsure if we should move that to common dir as that class isn't being used by any other module other than injector. But yeah..

Copy link
Contributor

Choose a reason for hiding this comment

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

In fact, we could move it to the common folder, but perhaps it is better that we wait to see what Kamil thinks about this move. 😄👍

@kamilmysliwiec
Copy link
Member

lgtm

@kamilmysliwiec kamilmysliwiec merged commit 7222cd1 into nestjs:master Jul 28, 2022
@micalevisk micalevisk deleted the feat/issue-9107 branch July 28, 2022 11:29
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.

Add ability to disable LazyModuleLoader's logging
4 participants