From fe6ef901b8393122aa988daf6d3a31fc9bec1bd4 Mon Sep 17 00:00:00 2001 From: joseph le Date: Fri, 29 Sep 2023 11:19:36 +0700 Subject: [PATCH] add middleware writeLog --- app/utils/Logger.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/utils/Logger.ts b/app/utils/Logger.ts index e9d5c3b..1fc4861 100644 --- a/app/utils/Logger.ts +++ b/app/utils/Logger.ts @@ -24,7 +24,7 @@ const shortenStringsInObject = (obj, maxLength) => { // Rút ngắn chuỗi lại maxLength ký tự obj = "[Array:"+obj.length+"]\n"+obj.slice(0,15) } - + return obj; } @@ -44,11 +44,15 @@ export function loggerAPI(request, response, location) { response.getStatus() + " - " + location + - "\n------------PAYLOAD-----------\n" + + "\n------PAYLOAD------\n" + JSON.stringify(request.all()) + - "\n--------------DATA-------------\n" + + "\n-------DATA--------\n" + JSON.stringify(body) + - "\n-------------------------------"; + "\n-------HEADERS--------\n" + + JSON.stringify(request.headers()) + + "\n-------PARAMS--------\n" + + JSON.stringify(request.params()) + + "\n\n======================================================================\n======================================================================"; fs.exists(fileName, async (exists) => { if (exists) {