Gatsby: chore: Move console overrides to reporter.log

Created on 17 Jun 2019  路  13Comments  路  Source: gatsbyjs/gatsby

We currently override console.log, console.warn, console.info and console.error in https://github.com/gatsbyjs/gatsby/blob/e034605e1c3ea47882dbf670c2eb1fb3ce3572fa/packages/gatsby-cli/src/reporter/index.js#L109


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)

https://github.com/yeoman/update-notifier/commit/c3b1df66fee922cae1af7c3ca898240c2df35884#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.

good first issue

All 13 comments

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

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

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

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

yes! All yours!

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

@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))

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

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

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

This was done in https://github.com/gatsbyjs/gatsby/pull/14956 by @leonlafa

@sidharthachatterjee is there something remaining in the issue?

@kushthedude I've reverted https://github.com/gatsbyjs/gatsby/pull/17838

In https://github.com/gatsbyjs/gatsby/pull/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 https://github.com/yeoman/update-notifier/issues/170

Was this page helpful?
0 / 5 - 0 ratings