Skip to content

Commit

Permalink
ref: improve logs
Browse files Browse the repository at this point in the history
  • Loading branch information
kristian4res committed Nov 4, 2024
1 parent f55a3ac commit 6a15aaa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions server/routes/blaiseApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ export default function blaiseApi(config: CustomConfig, auth: Auth, blaiseApiCli
auditLogger.error(req.log, "No user provided for deletion");
return res.status(400).json();
}
auditLogger.info(req.log, `${currentUser.name || "Unknown"} has successfully deleted user: ${user}`);
auditLogger.info(req.log, `${currentUser.name || "Unknown"} has successfully deleted user, ${user}`);
return res.status(204).json(await blaiseApiClient.deleteUser(user));
} catch (error) {
auditLogger.error(req.log, `Error whilst trying to delete user: ${error}`);
auditLogger.error(req.log, `Error whilst trying to delete user, ${req.headers.user}, with error message: ${error}`);
return res.status(500).json(error);
}
});
Expand Down
4 changes: 2 additions & 2 deletions server/tests/routes/blaiseApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ describe("DELETE /api/users endpoint", () => {
.set("user", username);

const log = logInfo.mock.calls[0][0];
expect(log).toEqual(`AUDIT_LOG: ${mockUser.name} has successfully deleted user: ${username}`);
expect(log).toEqual(`AUDIT_LOG: ${mockUser.name} has successfully deleted user, ${username}`);
expect(response.statusCode).toEqual(204);
blaiseApiMock.verify(a => a.deleteUser(It.isValue<string>(username)), Times.once());
});
Expand All @@ -188,7 +188,7 @@ describe("DELETE /api/users endpoint", () => {
.set("user", username);

const log = logError.mock.calls[0][0];
expect(log).toEqual(`AUDIT_LOG: Error whilst trying to delete user: ${errorMessage}`);
expect(log).toEqual(`AUDIT_LOG: Error whilst trying to delete user, ${username}, with error message: ${errorMessage}`);
expect(response.statusCode).toEqual(500);
blaiseApiMock.verify(a => a.deleteUser(It.isValue<string>(username)), Times.once());
expect(response.body).toStrictEqual(errorMessage);
Expand Down

0 comments on commit 6a15aaa

Please sign in to comment.