Changing logger to show url and method of route

This commit is contained in:
Collin Duncan 2023-01-29 17:56:19 +01:00
parent ef013d4744
commit 9ef3009cc2
No known key found for this signature in database

View file

@ -10,8 +10,8 @@ const server = http.createServer(async (req, res) => {
new Logger('request', v4(), LogLevel.DEBUG),
async () => {
const logger = asyncLocalStorage.getStore()
logger?.debug('Incoming request')
const { url, method } = req
logger?.debug('Incoming request', { url, method })
if (
!url ||
@ -19,7 +19,7 @@ const server = http.createServer(async (req, res) => {
!/^\/reservations$/.test(url) ||
method.toLowerCase() !== 'post'
) {
logger?.info('Not found')
logger?.info('Not found', { url, method })
res.writeHead(404, 'Not found')
res.end()
return