Skip to content
This repository has been archived by the owner on Dec 22, 2021. It is now read-only.

Structured logging RFC #31

Merged
merged 1 commit into from
Oct 18, 2019
Merged

Structured logging RFC #31

merged 1 commit into from
Oct 18, 2019

Conversation

m-allanson
Copy link
Contributor

@m-allanson m-allanson commented Feb 26, 2019

@stefanprobst
Copy link

stefanprobst commented Mar 19, 2019

  • I like that logging is handled by a redux action. This would also make it easier to find a uniform approach to how we log (validation) errors in action creators.
  • I don't think it's necessary to run the actions through the redux store. We could just catch log actions in a middleware and call the logger instance with the message there. So we'd have (i) a SET_LOGGER action that stores the logger instance in app state, and a LOG_MESSAGE action; (ii) a redux middleware that does something like store.getState().logger(action.payload) and does not call next().
  • Advantage of a middleware would also be that we could log all actions (and their payloads) if we wanted to.
  • Logging before the store is available (during early bootstrap?): would just use the logger instance directly.

@stefanprobst
Copy link

This is what it could look like with a middleware, and dispatching log actions. The only place where the old reporter is still directly imported is in bootstrap/index (and in the commands which haven't been touched).

gatsbyjs/gatsby@master...stefanprobst:redux-logger-middleware

Note: Not sure what the scope of the RFC actually is -- the above is not about displaying/formatting/persisting logs, but about forwarding log messages (and potentially every dispatched action) to a logger instance.

@stefanprobst
Copy link

This RFC has entered the final comment period.

@stefanprobst
Copy link

Some discussion on this in gatsbyjs/gatsby#13269

@agentofuser
Copy link

Regarding indexed error messages, I think TypeScript is a great example: https://github.com/Microsoft/TypeScript/blob/master/src/compiler/diagnosticMessages.json

Having unique error codes greatly helps searching the web for help. It also enables localization of error messages down the line.

Copy link
Contributor

@sidharthachatterjee sidharthachatterjee left a comment

Choose a reason for hiding this comment

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

This is complete so let's merge this in

@sidharthachatterjee sidharthachatterjee merged commit 46f150e into master Oct 18, 2019
@sidharthachatterjee sidharthachatterjee deleted the structured-logging branch October 18, 2019 16:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants