WIP: feat: add a custom server for logging ON-3130 #986
+55
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The only way I could find to get logging of all our HTTP requests was to create a custom server that loads NextJS itself.
https://nextjs.org/docs/pages/building-your-application/configuring/custom-server
I don't think this is the path we want to take; it means we lose a lot of NextJS features.
The next best solution I've seen is patching the NextJS library and adding your logging code directly to it! Which is definitely a lot worse.
If someone else gets a good idea of how to do detailed server-side logging on the app, please let me know. Right now I'm stumped.
Description by Korbit AI
What change is being made?
Add a custom server for logging HTTP requests using
pino-http
in theserver.ts
file and update dependencies accordingly inpackage.json
andpackage-lock.json
.Why are these changes being made?
These changes introduce structured logging to our server for better monitoring and debugging capabilities, using
pino-http
for efficient HTTP request logs. This enhancement aligns with ON-3130 user story requirements, ensuring that any errors and significant events can be logged at appropriate levels for improved observability.