From bc19538431930591674e6790abb0bebd3b099c90 Mon Sep 17 00:00:00 2001 From: joseph le Date: Fri, 29 Sep 2023 11:12:56 +0700 Subject: [PATCH] add middleware writeLog --- app/utils/Logger.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/utils/Logger.ts b/app/utils/Logger.ts index dd9e617..e9d5c3b 100644 --- a/app/utils/Logger.ts +++ b/app/utils/Logger.ts @@ -16,14 +16,15 @@ const shortenStringsInObject = (obj, maxLength) => { // Rút ngắn chuỗi lại maxLength ký tự obj[key] = obj[key].substring(0, maxLength); } - - if (Array.isArray(obj[key]) && obj[key].length > 10) { - // Rút ngắn chuỗi lại maxLength ký tự - obj[key] = "[Array:"+obj[key].length+"]" - } } } + + if (Array.isArray(obj) && obj.length > 10) { + // Rút ngắn chuỗi lại maxLength ký tự + obj = "[Array:"+obj.length+"]\n"+obj.slice(0,15) + } + return obj; }