From a85d530384761a0af833caac9b38b9834517c9fa Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 17 Aug 2022 14:58:40 +0200 Subject: Remove unnecessary logs --- server/middlewares/validators/shared/utils.ts | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'server/middlewares/validators/shared') diff --git a/server/middlewares/validators/shared/utils.ts b/server/middlewares/validators/shared/utils.ts index 77b64bc7a..f39128fdd 100644 --- a/server/middlewares/validators/shared/utils.ts +++ b/server/middlewares/validators/shared/utils.ts @@ -3,7 +3,32 @@ import { param, validationResult } from 'express-validator' import { isIdOrUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc' import { logger } from '../../../helpers/logger' -function areValidationErrors (req: express.Request, res: express.Response) { +function areValidationErrors ( + req: express.Request, + res: express.Response, + options: { + omitLog?: boolean + omitBodyLog?: boolean + tags?: string[] + } = {}) { + const { omitLog = false, omitBodyLog = false, tags = [] } = options + + if (!omitLog) { + logger.debug( + 'Checking %s - %s parameters', + req.method, req.originalUrl, + { + body: omitBodyLog + ? 'omitted' + : req.body, + params: req.params, + query: req.query, + files: req.files, + tags + } + ) + } + const errors = validationResult(req) if (!errors.isEmpty()) { -- cgit v1.2.3