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

Add server side logging to ExpressError and new Error types. #184

Open
hiyaryan opened this issue Oct 31, 2024 · 2 comments
Open

Add server side logging to ExpressError and new Error types. #184

hiyaryan opened this issue Oct 31, 2024 · 2 comments
Labels
api Improvements to the API feature New feature patch Related to a patch release todo Related to dev TODO comments in source

Comments

@hiyaryan
Copy link
Member

TODO added to line 116 of requestBetaAccess function in middelware/access.ts

TODO: Add server-side logging for errors; Expand ExpressError to include a log method to log errors from catch blocks to a file.

eslint-disable-next-line @typescript-eslint/no-unused-vars
ESLint disable comment used to allow err caught in catch block to not be used. The catch block simply passes an ExpressError to the error handler without using the runtime error stored in err.

This suggests that ExpressError can be expanded to include a logging feature as described in the TODO.

@hiyaryan hiyaryan added feature New feature patch Related to a patch release api Improvements to the API todo Related to dev TODO comments in source labels Oct 31, 2024
@davidzlu
Copy link
Collaborator

We might also want to consider having more elaborate typing for errors going forward, instead of having ExpressError as the catch-all. It increases complexity, but also lets you handle them more precisely. We also should take a look at the JS logging libraries out there and try integrating them rather than settling on console.log.

@hiyaryan hiyaryan changed the title Add server side logging to ExpressError. Add server side logging to ExpressError and new Error types. Nov 8, 2024
@hiyaryan
Copy link
Member Author

hiyaryan commented Nov 12, 2024

Note that the new services layer is printing errors to the console with console.error. This makes the output in the console very verbose.

Instead of logging the error to the console, the error should be logged in a file and timestamped. The morgan error should also be timestamped. Then whenever a server side error code ≥ 500 occurs, for example, the morgan error can be traced to the error in the log.

Note that morgan middleware does not have to be used if another logger is preferred for HTTP request/response logging.

#187

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Improvements to the API feature New feature patch Related to a patch release todo Related to dev TODO comments in source
Projects
None yet
Development

No branches or pull requests

2 participants