From 1cecc2cccd51f6bf26afd368adfd77eb0f7c86ae Mon Sep 17 00:00:00 2001 From: William Oldham Date: Sun, 5 Nov 2023 15:32:51 +0000 Subject: [PATCH] Ignore healthcheck and metrics --- src/services/logger.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/services/logger.ts b/src/services/logger.ts index 83ab54f..7237dae 100644 --- a/src/services/logger.ts +++ b/src/services/logger.ts @@ -64,6 +64,8 @@ export function scopedLogger(service: string, meta: object = {}) { return logger; } +const ignoredUrls = ['/healthcheck', '/metrics']; + export function makeFastifyLogger(logger: winston.Logger) { logger.format = winston.format.combine( winston.format((info) => { @@ -78,6 +80,9 @@ export function makeFastifyLogger(logger: winston.Logger) { let url = request.url; try { const pathParts = (request.url as string).split('?', 2); + + if (ignoredUrls.includes(pathParts[0])) return false; + if (pathParts[1]) { const searchParams = new URLSearchParams(pathParts[1]); pathParts[1] = searchParams.toString();