Add request logging using morgan

This commit adds request logging to the app using morgan.

Every request will now be logged not one but twice: one when the request is received, and a second time when the response is sent.

The response logging also prints out the time elapsed in processing the request, which will be useful to debug performance issues (calls to the dashboard home are currently taking 4 - 15s on a populated database).

The new code uses a tiny middleware that uses nanoid to generate a random request id that can be used to match requests in the logs.

This logging will help us determine which requests are successful, which requests are slow, and establish what requests may have contributed to causing an application crash, making future debugging easier.
This commit is contained in:
Jose Bolos
2022-03-07 18:35:25 +00:00
parent 321d7bb6ba
commit 9dbee59746
2 changed files with 32 additions and 0 deletions

View File

@@ -31,6 +31,8 @@
"http-headers": "~3.0.2",
"kleur": "~4.1.4",
"moment": "~2.29.1",
"morgan": "~1.10.0",
"nanoid": "~3.3.1",
"pa11y-webservice": "~4.0.0",
"pa11y-webservice-client-node": "~3.0.0",
"underscore": "~1.13.1"