inject logger

This commit is contained in:
Alex Holliday committed 2026-01-19 21:58:48 +00:00
1 parent 7c9410f9d7
commit bebb5d6942
9 files changed
+125 -18

No files matched your search

@@ -9,6 +9,7 @@ import {
import got from "got";
export class SlackProvider implements INotificationProvider {
constructor(private logger: any) {}
private getHardwareContent = (monitor: Monitor, monitorStatusResponse: MonitorStatusResponse) => {
const { alertsToSend } = buildHardwareAlerts("HOST_PLACEHOLDER", monitor, monitorStatusResponse);
const body = buildHardwareWebhookBody(alertsToSend, monitor);
@@ -33,6 +34,7 @@ export class SlackProvider implements INotificationProvider {
}
try {
this.logger?.debug?.("Sending Slack alert", { address: notification.address });
await got.post(notification.address, {
json: { text: body },
headers: {
@@ -42,6 +44,7 @@ export class SlackProvider implements INotificationProvider {
});
return true;
} catch (error) {
this.logger?.error?.("Slack alert failed", { error });
return false;
}
}
@@ -52,6 +55,7 @@ export class SlackProvider implements INotificationProvider {
}
try {
this.logger?.debug?.("Sending Slack test alert", { address: notification.address });
await got.post(notification.address, {
json: { text: getTestMessage() },
headers: {
@@ -61,6 +65,7 @@ export class SlackProvider implements INotificationProvider {
});
return true;
} catch (error) {
this.logger?.error?.("Slack test alert failed", { error });
return false;
}
}