Skip to content

Commit

Permalink
chore: improve log readability
Browse files Browse the repository at this point in the history
  • Loading branch information
rileydcampbell committed Nov 9, 2023
1 parent 6a4f732 commit 794eb24
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/handlers/order-notification/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export class OrderNotificationHandler extends DynamoStreamLambdaHandler<Containe
filler: newOrder.filler,
})

log.info({ order: newOrder, registeredEndpoints }, 'Sending order to registered webhooks.')

const requests: Promise<AxiosResponse>[] = registeredEndpoints.map((endpoint) =>
axios.post(
endpoint.url,
Expand Down Expand Up @@ -58,6 +60,7 @@ export class OrderNotificationHandler extends DynamoStreamLambdaHandler<Containe
results.forEach((result, index) => {
metrics.putMetric(`OrderNotificationAttempt-chain-${newOrder.chainId}`, 1)
if (result.status == 'fulfilled' && result?.value?.status >= 200 && result?.value?.status <= 202) {
delete result.value.request
log.info(
{ result: result.value },
`Success: New order record sent to registered webhook ${registeredEndpoints[index].url}.`
Expand Down
2 changes: 1 addition & 1 deletion test/handlers/order-notification.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('Testing new order Notification handler.', () => {
orderStatus: MOCK_ORDER.orderStatus.S,
filler: MOCK_ORDER.filler.S,
})
expect(logInfoMock).toBeCalledTimes(2)
expect(logInfoMock).toBeCalledTimes(3)
expect(logInfoMock).toBeCalledWith(
{ result: { status: 200 } },
'Success: New order record sent to registered webhook webhook.com/1.'
Expand Down

0 comments on commit 794eb24

Please sign in to comment.