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: restore 'debug' logs #151

Merged
merged 1 commit into from
Mar 5, 2025
Merged

Conversation

dpopp07
Copy link
Contributor

@dpopp07 dpopp07 commented Feb 17, 2025

Revert "Remove debug dependency", with the following changes:

  • Update "var" to "const" for debug imports
  • Preserve history file so intermediate versions are documented correctly
  • Use latest version of debug

This reverts commit 0b5a0a6.

Copy link
Contributor

@bjohansebas bjohansebas left a comment

Choose a reason for hiding this comment

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

LGTM, please add it to the history

@dpopp07
Copy link
Contributor Author

dpopp07 commented Feb 17, 2025

Note: as-is, this does NOT restore the ability to use DEBUG=express:* for viewing router logs. I don't think we should lose the scope of this package, since it's decoupled from Express.

If it was really important to restore that behavior, we could do something hacky like:

const debugCurrent = require('debug')('router')
const debugLegacy = require('debug')('express:router')

function debug(...args) {
  debugCurrent(...args)
  debugLegacy(...args)
}

I tested this and it seems to work fine. That said, I'd prefer not to add something like this.

I would rather open a follow-on PR in the v5 migration guide to explicitly state that router logs must now be viewed through the router scope (DEBUG=express:* -> DEBUG=express:*,router).

Let me know what y'all think. I'm open to other options as well.

Revert "Remove debug dependency", with the following changes:

- Update "var" to "const" for debug imports
- Preserve history file so intermediate versions are documented correctly
- Use latest version of debug

This reverts commit 0b5a0a6.
@dpopp07
Copy link
Contributor Author

dpopp07 commented Feb 18, 2025

please add it to the history

Done! I thought that might need to wait until the release, forgot about the "unreleased" pattern. Thanks for pointing it out.

@dpopp07
Copy link
Contributor Author

dpopp07 commented Feb 19, 2025

Re: my prior comment

I realized that if it's important to restore express:router debug logs and if we want to move in the direction of diagnostic channels, we could go ahead and implement diagnostic channels in this library that simply duplicate the current debug logs.

In Express, we could subscribe to this channel, re-print any messages with debug under the express:router namespace, and it should be just like old times. There may be hidden complexity and I haven't tested it but I think it should work.

@jonchurch this might have been what you suggested the other day, unless you were just proposing that diagnostic channels would be a better approach for the future. Either way, I'm curious what folks think about this.

@bjohansebas
Copy link
Contributor

I think diagnostic channels would be for a different PR, and technically this is a separate package, so it doesn’t make sense for debug to be used for express:router. This is not a blocking comment, though, in case another member suggests that it should observe express:router.

@dpopp07
Copy link
Contributor Author

dpopp07 commented Feb 19, 2025

Agreed, the express:router namespace should certainly not be defined in this package. The proposal is that an express:router debug namespace could be defined, in the express package, that effectively wraps messages published by the router package through a diagnostic channel.

I only suggest this as an option, in the case that it is important to restore express:router debug logs in the express package to what they were in v4 before going latest with v5. If it's not, I would prefer merging this as-is and updating the migration guide accordingly.

Update: My original motivation for suggesting this is that the related issue referred to expected logs missing from express:*. This comment says:

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

This is a potential, though not ideal, solution.

@bjohansebas
Copy link
Contributor

At this point, the best option is to update the migration guide about the fact that express:router in debug no longer exists, since it was a breaking change and no longer exists in [email protected].

The diagnostic channel would be great to try in the future.

@dpopp07
Copy link
Contributor Author

dpopp07 commented Feb 20, 2025

I agree. Unless there are any objections before I get to it, I'll go ahead and open that PR against the migration guide

@dpopp07
Copy link
Contributor Author

dpopp07 commented Feb 25, 2025

I opened the follow up PR to the migration guide: expressjs/expressjs.com#1819

This PR will need to be merged and released before that documentation is accurate.

Copy link
Member

@wesleytodd wesleytodd left a comment

Choose a reason for hiding this comment

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

Awesome! I don't think we should bring back express:* to include router, but it might mean we need to add some migration docs on this right? This is technically a breaking change we did already by removing it, so adding it here as the router scope is pretty reasonable and forward moving imo.

@dpopp07
Copy link
Contributor Author

dpopp07 commented Mar 4, 2025

Sounds good!

it might mean we need to add some migration docs on this right?

Yes - I opened a draft PR updating the migration docs. See my previous comment 🙂

@wesleytodd wesleytodd merged commit 79a8add into pillarjs:master Mar 5, 2025
9 checks passed
@dpopp07 dpopp07 deleted the dp/restore-debug branch March 5, 2025 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants