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

graphql-tools/load: use debug to log timers and errors #4886

Closed
wants to merge 3 commits into from

Conversation

ldiqual
Copy link
Contributor

@ldiqual ldiqual commented Dec 7, 2022

Description

Instead of using console.time and console.error, this PR refactors @graphql-tools/load to use debug, activated via DEBUG=graphql-tools/load.

debug is a very popular package used by libraries to log messages and allow the end-user to enable/disable logs with specific prefixes. For instance, to enable debug logs in eslint, you would run DEBUG=eslint yarn eslint. This PR applies the same concept to graphql-tools/load, where as in the old code it would print debug logs for any value of DEBUG.

Fixes #4777

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Screenshots/Sandbox (if appropriate/relevant):

Debug logs will print like this:

image

How Has This Been Tested?

Ran yarn test packages/load/ and made sure the logs print properly with DEBUG=graphql-tools/load

Test Environment:

  • OS: macOS 13.0
  • @graphql-tools/load: 7.8.6
  • NodeJS: v18.12.1

Checklist:

  • I have followed the CONTRIBUTING doc and the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests and linter rules pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@changeset-bot
Copy link

changeset-bot bot commented Dec 7, 2022

🦋 Changeset detected

Latest commit: 4c94363

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@graphql-tools/load Minor
@graphql-tools/node-require Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ldiqual
Copy link
Contributor Author

ldiqual commented Jan 19, 2023

@ardatan Sorry to bother – just want to make sure this is on your radar. Is there anything I can do to get this merged in?

@TSMMark
Copy link

TSMMark commented Jan 26, 2023

Please merge this!

The giant wall of text prints AFTER the lint results — so you can't even see your own lint results without scrolling up 20 pages of spam.

Please

@adrienharnay
Copy link

Any news on this PR?

@ardatan
Copy link
Owner

ardatan commented Nov 23, 2023

Thanks for the PR, sorry for not responding so long!
But I think we can solve this without introducing a new dependency.
I merged a different PR by keeping your credit in the CHANGELOG and commit history!
Again thanks for the contribution!

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.

@graphql-tools/load outputs debug logs for any value of DEBUG
4 participants