From 08379ba141effcb5e9e5ef4dd6073e166bd78135 Mon Sep 17 00:00:00 2001 From: Marco Klein Date: Tue, 3 Oct 2023 13:28:53 +0200 Subject: [PATCH] feat: :loud_sound: Add response body logging --- src/app.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app.ts b/src/app.ts index 2ed7dc3..142d737 100644 --- a/src/app.ts +++ b/src/app.ts @@ -169,9 +169,14 @@ export class App { this._logger.debug(`${prefix} Body received (RAW): ${request.rawBody}`); this._logger.debug(`${prefix} Body received: ${JSON.stringify(request.body)}`); + var data = ""; + + response.on('data', (chunk) => data += chunk) + response.on("finish", () => { this._logger.info(`${prefix} END with ${response.statusCode}`); - this._logger.debug(`${prefix} ${JSON.stringify(response.headersSent)}`); + this._logger.debug(`${prefix} Headers sent: ${JSON.stringify(response.headersSent)}`); + this._logger.debug(`${prefix} Body sent: ${data}`); }); next();