grassrootsgrocery / admin-portal

GNU Affero General Public License v3.0
10 stars 5 forks source link

Need to log errors to server log in messaging.ts #48

Closed mattsahn closed 1 year ago

mattsahn commented 1 year ago

Dan reported that triggering Make automations isn't working in the frontend. The app does catch and propagate error messages to the user, but they're currently not being logged in the server log (STDOUT) at all. So, it's impossible to find when that happened and any other details around the what happened with those failures.

Those cases of errors in the server should be logged (see issue #45) in the messaging area and generally throughout the server code across the board. The server log is key to being able to investigate issues that have been reported by users so it needs to have all errors logged there (with timestamps!).

https://github.com/grassrootsgrocery/admin-portal/blob/682f166ed5053e061ea2acdf875462bbccf9a458/server/routes/messaging.ts#L64

mattsahn commented 1 year ago

This Issue is ready for development since Issue #45 is complete. In all of the server code, anywhere there are lines throwing an error, there should be a corresponding logger() line so that it's logged to STDOUT where we can see in the logs.

zuechai commented 1 year ago

Do we want to log the instances of this thrown object (occurs in each route)?

if (!resp.ok) {
  throw {
    message: MAKE_ERROR_MESSAGE,
    status: resp.status,
  };
mattsahn commented 1 year ago

Yeah, let's log any of these errors. We'll want a record in the log anytime they're encountered.

zuechai commented 1 year ago

I am deleting the branch I was working on originally and creating a new branch and PR. Linked below is the one-line solution to log all errors to the server. We will want to remove all other logger.error("") calls to prevent duplicate logs to the server.

https://github.com/grassrootsgrocery/admin-portal/pull/65#issuecomment-1469232545

zuechai commented 1 year ago

@mattsahn @jasoncavanaugh I realized that the way I set up the logger the stack trace isn't printed to the server in production. That's an easy fix that I can make with this branch. I want to remove some commented code in that file, anyway. Is there any reason not to include the stack? Looking back at the articles Matt referenced in #45 they say to include it in the server log.