Skip to content

Add control over mounting debug message on application startup #235

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

Open
wilfreud opened this issue Apr 6, 2025 · 5 comments
Open

Add control over mounting debug message on application startup #235

wilfreud opened this issue Apr 6, 2025 · 5 comments
Labels
contribution welcome This is a good candidate for a community contribution enhancement New feature or request

Comments

@wilfreud
Copy link

wilfreud commented Apr 6, 2025

There is this message on startup " DEBUG [ClsModule] Mounting ClsMiddleware to *", even in production.
It just bothers me

@Papooch Papooch added enhancement New feature or request contribution welcome This is a good candidate for a community contribution labels Apr 6, 2025
@Papooch
Copy link
Owner

Papooch commented Apr 7, 2025

I've been thinking about adding a bunch of other logs for debugging, akin to nestjs/nest#7910. This issue could be implemented together with it.

@wilfreud
Copy link
Author

wilfreud commented Apr 9, 2025

That sounds good. plus adding some sort of control over those logs would be good. That was the main point of me issue, I just realized I forgot to mention on.

@Papooch
Copy link
Owner

Papooch commented Apr 9, 2025

I'm thinking of these possible options:

  • CLS_DEBUG=true - enables only debug logs from this library
  • NEST_DEBUG=true - enables debug logs for Nest and this library
  • NEST_DEBUG=true - enables only debug logs for Nest + NEST_DEBUG=nestjs-cls - enables debug logs for Nest and this library
  • DEBUG=nestjs-cls - enables only debug logs from this library, possibly in combination with other libraries that also use the DEBUG env var (DEBUG=express,nestjs-cls)

@wilfreud
Copy link
Author

wilfreud commented Apr 9, 2025

Sounds good.

I was thinking more of a programatical to do it, like passing an object in the forRoot method.

ClsModule.forRoot({
      global: true,
      middleware: { mount: true },
}),

But I think doing both could be great, providing two ways of doing it. Though there would be a need to define precedence between envs & config object.

PS: why the NEST_DEBUG for control over NestJS logs themselves ? (I feel like I'm missing something)

@Papooch
Copy link
Owner

Papooch commented May 5, 2025

why the NEST_DEBUG for control over NestJS logs themselves

NEST_DEBUG already controls NestJS's own debug logs when it is set to any value. I was thinking I could use the same variable to also enable debug logs of nestjs-cls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution welcome This is a good candidate for a community contribution enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants