Merge branch 'develop' into dev
This commit is contained in:
commit
fb50edf580
1 changed files with 12 additions and 1 deletions
|
|
@ -59,6 +59,17 @@ async function logMiddleware(req: Request, res: Response, next: NextFunction) {
|
||||||
// Get rootId from token
|
// Get rootId from token
|
||||||
const rootId = req.app.locals.logData?.orgRootDnaId;
|
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 = {
|
const obj = {
|
||||||
logType: res.statusCode >= 500 ? "error" : res.statusCode >= 400 ? "warning" : "info",
|
logType: res.statusCode >= 500 ? "error" : res.statusCode >= 400 ? "warning" : "info",
|
||||||
ip: req.ip,
|
ip: req.ip,
|
||||||
|
|
@ -71,7 +82,7 @@ async function logMiddleware(req: Request, res: Response, next: NextFunction) {
|
||||||
method: req.method,
|
method: req.method,
|
||||||
endpoint: req.url,
|
endpoint: req.url,
|
||||||
responseCode: String(res.statusCode === 304 ? 200 : res.statusCode),
|
responseCode: String(res.statusCode === 304 ? 200 : res.statusCode),
|
||||||
responseDescription: data?.message,
|
responseDescription: _msg,
|
||||||
input: level === 4 ? JSON.stringify(req.body, null, 2) : undefined,
|
input: level === 4 ? JSON.stringify(req.body, null, 2) : undefined,
|
||||||
output: level === 4 ? JSON.stringify(data, null, 2) : undefined,
|
output: level === 4 ? JSON.stringify(data, null, 2) : undefined,
|
||||||
...req.app.locals.logData,
|
...req.app.locals.logData,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue