diff --git a/src/middlewares/logs.ts b/src/middlewares/logs.ts index 2ae251c..4bcf111 100644 --- a/src/middlewares/logs.ts +++ b/src/middlewares/logs.ts @@ -59,17 +59,6 @@ async function logMiddleware(req: Request, res: Response, next: NextFunction) { // Get rootId from token const rootId = req.app.locals.logData?.orgRootDnaId; - let _msg = data?.message; - if (!_msg) { - if (res.statusCode >= 500) { - _msg = "ไม่สำเร็จ"; - } else if (res.statusCode >= 400) { - _msg = "พบข้อผิดพลาด"; - } else if (res.statusCode >= 200) { - _msg = "สำเร็จ"; - } - } - const obj = { logType: res.statusCode >= 500 ? "error" : res.statusCode >= 400 ? "warning" : "info", ip: req.ip, @@ -82,7 +71,7 @@ async function logMiddleware(req: Request, res: Response, next: NextFunction) { method: req.method, endpoint: req.url, responseCode: String(res.statusCode === 304 ? 200 : res.statusCode), - responseDescription: _msg, + responseDescription: data?.message, input: level === 4 ? JSON.stringify(req.body, null, 2) : undefined, output: level === 4 ? JSON.stringify(data, null, 2) : undefined, ...req.app.locals.logData,