replaced some console.errors with logger

This commit is contained in:
jackiettran
2026-01-10 20:47:29 -05:00
parent 86cb8b3fe0
commit 415bcc5021
15 changed files with 165 additions and 174 deletions

View File

@@ -1,6 +1,7 @@
const { SESClient, SendEmailCommand } = require("@aws-sdk/client-ses");
const { getAWSConfig } = require("../../../config/aws");
const { htmlToPlainText } = require("./emailUtils");
const logger = require("../../../utils/logger");
/**
* EmailClient handles AWS SES configuration and core email sending functionality
@@ -44,9 +45,9 @@ class EmailClient {
this.sesClient = new SESClient(awsConfig);
this.initialized = true;
console.log("AWS SES Email Client initialized successfully");
logger.info("AWS SES Email Client initialized successfully");
} catch (error) {
console.error("Failed to initialize AWS SES Email Client:", error);
logger.error("Failed to initialize AWS SES Email Client", { error });
throw error;
}
})();
@@ -69,7 +70,7 @@ class EmailClient {
// Check if email sending is enabled in the environment
if (!process.env.EMAIL_ENABLED || process.env.EMAIL_ENABLED !== "true") {
console.log("Email sending disabled in environment");
logger.debug("Email sending disabled in environment");
return { success: true, messageId: "disabled" };
}
@@ -115,12 +116,10 @@ class EmailClient {
const command = new SendEmailCommand(params);
const result = await this.sesClient.send(command);
console.log(
`Email sent successfully to ${to}, MessageId: ${result.MessageId}`
);
logger.info("Email sent successfully", { to, messageId: result.MessageId });
return { success: true, messageId: result.MessageId };
} catch (error) {
console.error("Failed to send email:", error);
logger.error("Failed to send email", { error, to });
return { success: false, error: error.message };
}
}