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

chore: Move console overrides to reporter.log #14834

Closed
sidharthachatterjee opened this issue Jun 17, 2019 · 13 comments
Closed

chore: Move console overrides to reporter.log #14834

sidharthachatterjee opened this issue Jun 17, 2019 · 13 comments
Assignees
Labels
good first issue Issue that doesn't require previous experience with Gatsby

Comments

@sidharthachatterjee
Copy link
Contributor

sidharthachatterjee commented Jun 17, 2019

We currently override console.log, console.warn, console.info and console.error in

console.log = (...args) => reporter.log(util.format(...args))

This can get a little messy sometimes

Screenshot 2019-06-17 18 30 07

In this case, the log from update-notifier shows up as an error. update-notifier correctly calls console.error (because they want to log to stderr) but this isn't really an error for us and shouldn't show up as one (and potentially confuse some users)

yeoman/update-notifier@c3b1df6#diff-168726dbe96b3ce427e7fedce31bb0bc

We want to move our console overrides to reporter.log. Console messages will still show pretty in ink but won't have a prefix (success, error, warn, info). We want to move towards a future where all gatsby stuff uses the reported directly.

@sidharthachatterjee sidharthachatterjee added not stale status: blocked This issue/PR can't be solved at the moment and shouldn't be closed/merged labels Jun 17, 2019
@gatsbyjs gatsbyjs deleted a comment from sidharthachatterjee Jun 17, 2019
@sidharthachatterjee sidharthachatterjee added good first issue Issue that doesn't require previous experience with Gatsby and removed status: blocked This issue/PR can't be solved at the moment and shouldn't be closed/merged labels Jun 17, 2019
@wardpeet
Copy link
Contributor

I removed the comment about this being blocked. I updated the issue so it's not blocking anymore.

@sidharthachatterjee sidharthachatterjee changed the title chore: Remove console overrides chore: Move console overrides to reporter.log Jun 17, 2019
@wardpeet wardpeet added status: assigned and removed good first issue Issue that doesn't require previous experience with Gatsby labels Jun 17, 2019
@wardpeet
Copy link
Contributor

I'm going to use this one in my pairing session with someone. Sorry, it's taken ^^

@sidharthachatterjee sidharthachatterjee added good first issue Issue that doesn't require previous experience with Gatsby and removed status: assigned labels Jun 18, 2019
@sidharthachatterjee
Copy link
Contributor Author

This is back for the taking since the pairing session was a no show 😱

@leonlafa
Copy link

I'm happy to go through and refactor if it's still up for grabs?

@wardpeet
Copy link
Contributor

yes! All yours!

@leonlafa
Copy link

leonlafa commented Jun 18, 2019

Just to clarify, you want all of the console logs in the file above to be refactored as ...reporter.log(util.format(...args))?

@sidharthachatterjee
Copy link
Contributor Author

@leonlafa

Just to clarify, you want all of the console logs in the file above to be refactored as ...reporter.log(util.format(...args))?

Yeah, all of them (console.log, console.warn, console.info and console.error) should call reporter.log(util.format(...args))

@leonlafa
Copy link

@sidharthachatterjee thanks, I'll start work on this tonight.

@leonlafa
Copy link

Anyone about to quickly review my PR? @wardpeet @sidharthachatterjee

@leonlafa leonlafa self-assigned this Jun 21, 2019
@kushthedude
Copy link

@sidharthachatterjee Can I work on this, I see there are still console.log present in directory?

@sidharthachatterjee
Copy link
Contributor Author

This was done in #14956 by @leonlafa

@kushthedude
Copy link

@sidharthachatterjee is there something remaining in the issue?

@sidharthachatterjee
Copy link
Contributor Author

sidharthachatterjee commented Sep 24, 2019

@kushthedude I've reverted #17838

In #14973, we noticed that the overrides would cause any logs via console.warn, console.error or console.info to have their "level" reported incorrectly.

Incorrect reporting of levels is unfortunately pretty bad and I would consider the benefit of fixing that versus the problem that this issue describes a reasonable tradeoff.

For now, I'll be closing this and will open an issue upstream in https://github.com/yeoman/update-notifier and see if we can fix it there! 🙂

Edit: Opened yeoman/update-notifier#170

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issue that doesn't require previous experience with Gatsby
Projects
None yet
Development

No branches or pull requests

5 participants