Skip to content

Commit

Permalink
Properly pass module to LogService calls in MatrixHttpClient (#229)
Browse files Browse the repository at this point in the history
A followup to #186, that either slipped through the cracks or was lost
to merge conflict resolutions.

Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com>
Co-authored-by: Travis Ralston <travpc@gmail.com>
  • Loading branch information
3 people authored Jun 29, 2022
1 parent fa39409 commit e9dfb78
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,19 @@ export async function doHttpRequest(
const errBody = response.body || resBody;
if (typeof (errBody) === "object" && 'errcode' in errBody) {
const redactedBody = respIsBuffer ? '<Buffer>' : redactObjectForLogging(errBody);
LogService.error("MatrixHttpClient (REQ-" + requestId + ")", redactedBody);
LogService.error("MatrixHttpClient", "(REQ-" + requestId + ")", redactedBody);
throw new MatrixError(errBody, response.statusCode);
}

// Don't log the body unless we're in debug mode. They can be large.
if (LogService.level.includes(LogLevel.TRACE)) {
const redactedBody = respIsBuffer ? '<Buffer>' : redactObjectForLogging(response.body);
LogService.trace("MatrixHttpClient (REQ-" + requestId + " RESP-H" + response.statusCode + ")", redactedBody);
LogService.trace("MatrixHttpClient", "(REQ-" + requestId + " RESP-H" + response.statusCode + ")", redactedBody);
}

if (response.statusCode < 200 || response.statusCode >= 300) {
const redactedBody = respIsBuffer ? '<Buffer>' : redactObjectForLogging(response.body);
LogService.error("MatrixHttpClient (REQ-" + requestId + ")", redactedBody);
LogService.error("MatrixHttpClient", "(REQ-" + requestId + ")", redactedBody);
throw response;
}
return raw ? response : resBody;
Expand Down

0 comments on commit e9dfb78

Please sign in to comment.