Skip to content

Commit

Permalink
feat: 🔊 Add response body logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Hobart2967 committed Oct 3, 2023
1 parent 62b140d commit 08379ba
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 08379ba

Please sign in to comment.