From 5f68d08cbce0df3eebe16f9e5db9996991dd7bb1 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 21 Jul 2018 02:18:35 +0900 Subject: [PATCH] Improve log --- src/server/api/call.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/server/api/call.ts b/src/server/api/call.ts index fa13deb6b..6bab460e1 100644 --- a/src/server/api/call.ts +++ b/src/server/api/call.ts @@ -46,12 +46,14 @@ export default (endpoint: string, user: IUser, app: IApp, data: any, file?: any) // API invoking try { - const a = performance.now(); + const before = performance.now(); res = await exec(data, user, app); - const b = performance.now(); + const after = performance.now(); - if (b - a > 500) { - console.warn(`SLOW API CALL DETECTED: ${ep.name}`); + const time = after - before; + + if (time > 500) { + console.warn(`SLOW API CALL DETECTED: ${ep.name} (${ time }ms)`); } } catch (e) { rej(e);