question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add ability to disable LazyModuleLoader's logging

See original GitHub issue

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

As a serverless user, I love the ability to lazy load services!

The only thing I would change is the ability to disable the logging of each dependent service when initializing a lazy-loaded module.

See below for the default behavior:

image

Describe the solution you’d like

I’d leave this to the contributors, but maybe a second parameter added to the load method would work okay, such as:

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

return module.get(Service);

Again, 100% up to the frameworks designer for the best way to design the API

My current workaround is to extend the logger and add a list of contexts that I skip when logging an entry.

Teachability, documentation, adoption, migration strategy

Users can choose to disable/override/change the default behavior, eg. logging each dependency that gets initialized. The API above would be one way.

What is the motivation / use case for changing the behavior?

I lazy load a lot, and I’d love to see cleaner logs.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
kamilmysliwieccommented, Apr 11, 2022

“interface 1” option would be great to have @micalevisk!

1reaction
kamilmysliwieccommented, Jun 24, 2022

the disabling part is easy to achieve, but allow passing another logger instance or class ref is not. We cannot just override the logger like how is done below otherwise we will be changing the ‘main’ logger

So let’s just implement the disabling part for the time being. I can’t think of a use case where using a separate logger class (specifically for lazy-loaded modules) would make sense anyway.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to turn off Serilog? - Stack Overflow
Log levels can be modified at runtime with LoggingLevelSwitch : var ls = new LoggingLevelSwitch(); Log.Logger = new LoggerConfiguration() .MinimumLevel.
Read more >
Enabling and Disabling Logging Messages
The following paragraphs show the commands to enable and disable logging messages, and provide examples of the resulting messages.
Read more >
ADD ABILITY TO DISABLE LOGGING OF SECJ0371W ... - IBM
For instance a client continues to send an expired token repeatedly. The customer is requesting the ability to disable the logging of the...
Read more >
How to Disable Console Logging in Spring Boot - Baeldung
Learn how to configure a Spring Boot application so that it does not log to the console, whether it is using Logback, Log4j2, ......
Read more >
Solved: Can we disable logging levels display for a partic...
Do you think this is a common problem that requires a new feature in Bamboo? I'm asking this one because I was not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found