add logging (#187)

This commit is contained in:
KM Koushik
2025-07-26 20:05:34 +10:00
committed by GitHub
parent 5612d7a3eb
commit 202fbeacb6
24 changed files with 490 additions and 134 deletions

View File

@@ -5,6 +5,7 @@ import * as ses from "~/server/aws/ses";
import { db } from "~/server/db";
import { SesSettingsService } from "./ses-settings-service";
import { UnsendApiError } from "../public-api/api-error";
import { logger } from "../logger/log";
const dnsResolveTxt = util.promisify(dns.resolveTxt);
@@ -60,7 +61,7 @@ export async function createDomain(
) {
const domainStr = tldts.getDomain(name);
console.log("Creating domain", { domainStr, name, region });
logger.info({ domainStr, name, region }, "Creating domain");
if (!domainStr) {
throw new Error("Invalid domain");
@@ -191,7 +192,7 @@ async function getDmarcRecord(domain: string) {
const dmarcRecord = await dnsResolveTxt(`_dmarc.${domain}`);
return dmarcRecord;
} catch (error) {
console.error("Error fetching DMARC record:", error);
logger.error({ err: error, domain }, "Error fetching DMARC record");
return null; // or handle error as appropriate
}
}