Changing logger to show url and method of route
This commit is contained in:
parent
ef013d4744
commit
9ef3009cc2
1 changed files with 2 additions and 2 deletions
|
|
@ -10,8 +10,8 @@ const server = http.createServer(async (req, res) => {
|
||||||
new Logger('request', v4(), LogLevel.DEBUG),
|
new Logger('request', v4(), LogLevel.DEBUG),
|
||||||
async () => {
|
async () => {
|
||||||
const logger = asyncLocalStorage.getStore()
|
const logger = asyncLocalStorage.getStore()
|
||||||
logger?.debug('Incoming request')
|
|
||||||
const { url, method } = req
|
const { url, method } = req
|
||||||
|
logger?.debug('Incoming request', { url, method })
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!url ||
|
!url ||
|
||||||
|
|
@ -19,7 +19,7 @@ const server = http.createServer(async (req, res) => {
|
||||||
!/^\/reservations$/.test(url) ||
|
!/^\/reservations$/.test(url) ||
|
||||||
method.toLowerCase() !== 'post'
|
method.toLowerCase() !== 'post'
|
||||||
) {
|
) {
|
||||||
logger?.info('Not found')
|
logger?.info('Not found', { url, method })
|
||||||
res.writeHead(404, 'Not found')
|
res.writeHead(404, 'Not found')
|
||||||
res.end()
|
res.end()
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue