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

DEBUG=express:* does not work in [email protected] #6280

Open
cp3hnu opened this issue Jan 17, 2025 · 6 comments
Open

DEBUG=express:* does not work in [email protected] #6280

cp3hnu opened this issue Jan 17, 2025 · 6 comments
Labels

Comments

@cp3hnu
Copy link

cp3hnu commented Jan 17, 2025

Description

Debugging Express said
"To see all the internal logs used in Express, set the DEBUG environment variable to express:* when launching your app."
DEBUG=express:* node index.js

But it does not work in [email protected]
There is also no answer on Moving to Express 5

Expectations

How to debug in [email protected]?

@jonchurch
Copy link
Member

jonchurch commented Jan 17, 2025

express:application scope debugging is coming through fine.

But notably express:router is not coming through. In v5 router was moved out into another package, seems to have dropped the debug lib. I dont know that the exclusion was on purpose, cc @wesleytodd

An aside, splitting like this makes it more difficult to debug router under the express:* namespace. Not impossible, but something to solve for.

@jonchurch jonchurch added the 5.x label Jan 17, 2025
@UlisesGascon
Copy link
Member

I dont know that the exclusion was on purpose

+1 AFAIK this was not an intended move. I will consider this as a bug and one of the reason to not tag express@5 as latest in npm

@bjohansebas
Copy link
Member

This doesn't seem to be a bug, it was done in this commit(pillarjs/router@0b5a0a6) and is listed in the changelog for releasing version 2 of the router (pillarjs/router#60).

Although +1 on bringing it back, it's useful for debugging while we have a new logger.

@azadsingh99
Copy link

Directly using DEBUG=express:* node index.js because express no longer directly using the debug package
however we can add internal logs into the middleware for tracking

app.use((req, res, next) => {
  console.log(`[DEBUG] ${req.method} ${req.url}`);
  next();
});

@wesleytodd
Copy link
Member

I swear I had written a reply to this, sorry I must have accidentally forgotten to hit send, sorry. Maybe was it on the router repo or slack or something? Either way, I from what @bjohansebas showed it was done on purpose, I just wish we knew more than what the router repo shows.

In the long run I would very much like to remove this dependency and use a proper logger (pino) by default. This has a bunch of benefits, but mainly unifying the app logging and framework logging lets authors have consistent formatting and log handling.

So, for today since the change landed nearly 4 years ago and folks are just now noticing, lets not make a hasty decision? We can for sure add this to the "fix before latest" release, but I think we should see if we could easily land a logger integration, since that would be long term better anyway.

@krzysdz
Copy link
Contributor

krzysdz commented Jan 20, 2025

There was a discussion about removing debug in router in 2017: pillarjs/router#57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants