replaced some console.errors with logger
This commit is contained in:
@@ -34,7 +34,7 @@ class RentalFlowEmailService {
|
||||
]);
|
||||
|
||||
this.initialized = true;
|
||||
console.log("Rental Flow Email Service initialized successfully");
|
||||
logger.info("Rental Flow Email Service initialized successfully");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,7 +104,7 @@ class RentalFlowEmailService {
|
||||
htmlContent
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Failed to send rental request email:", error);
|
||||
logger.error("Failed to send rental request email", { error });
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
}
|
||||
@@ -171,7 +171,7 @@ class RentalFlowEmailService {
|
||||
htmlContent
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Failed to send rental request confirmation email:", error);
|
||||
logger.error("Failed to send rental request confirmation email", { error });
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
}
|
||||
@@ -324,10 +324,7 @@ class RentalFlowEmailService {
|
||||
htmlContent
|
||||
);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
"Failed to send rental approval confirmation email:",
|
||||
error
|
||||
);
|
||||
logger.error("Failed to send rental approval confirmation email", { error });
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
}
|
||||
@@ -410,7 +407,7 @@ class RentalFlowEmailService {
|
||||
htmlContent
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Failed to send rental declined email:", error);
|
||||
logger.error("Failed to send rental declined email", { error });
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
}
|
||||
@@ -544,7 +541,7 @@ class RentalFlowEmailService {
|
||||
|
||||
return await this.emailClient.sendEmail(userEmail, subject, htmlContent);
|
||||
} catch (error) {
|
||||
console.error("Failed to send rental confirmation:", error);
|
||||
logger.error("Failed to send rental confirmation", { error });
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
}
|
||||
@@ -608,21 +605,19 @@ class RentalFlowEmailService {
|
||||
false // isRenter = false for owner
|
||||
);
|
||||
if (ownerResult.success) {
|
||||
console.log(
|
||||
`Rental confirmation email sent to owner: ${owner.email}`
|
||||
);
|
||||
logger.info("Rental confirmation email sent to owner", { email: owner.email });
|
||||
results.ownerEmailSent = true;
|
||||
} else {
|
||||
console.error(
|
||||
`Failed to send rental confirmation email to owner (${owner.email}):`,
|
||||
ownerResult.error
|
||||
);
|
||||
logger.error("Failed to send rental confirmation email to owner", {
|
||||
email: owner.email,
|
||||
error: ownerResult.error,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`Failed to send rental confirmation email to owner (${owner.email}):`,
|
||||
error.message
|
||||
);
|
||||
logger.error("Failed to send rental confirmation email to owner", {
|
||||
email: owner.email,
|
||||
error,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -637,28 +632,23 @@ class RentalFlowEmailService {
|
||||
true // isRenter = true for renter (enables payment receipt)
|
||||
);
|
||||
if (renterResult.success) {
|
||||
console.log(
|
||||
`Rental confirmation email sent to renter: ${renter.email}`
|
||||
);
|
||||
logger.info("Rental confirmation email sent to renter", { email: renter.email });
|
||||
results.renterEmailSent = true;
|
||||
} else {
|
||||
console.error(
|
||||
`Failed to send rental confirmation email to renter (${renter.email}):`,
|
||||
renterResult.error
|
||||
);
|
||||
logger.error("Failed to send rental confirmation email to renter", {
|
||||
email: renter.email,
|
||||
error: renterResult.error,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`Failed to send rental confirmation email to renter (${renter.email}):`,
|
||||
error.message
|
||||
);
|
||||
logger.error("Failed to send rental confirmation email to renter", {
|
||||
email: renter.email,
|
||||
error,
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(
|
||||
"Error fetching user data for rental confirmation emails:",
|
||||
error
|
||||
);
|
||||
logger.error("Error fetching user data for rental confirmation emails", { error });
|
||||
}
|
||||
|
||||
return results;
|
||||
@@ -824,16 +814,17 @@ class RentalFlowEmailService {
|
||||
);
|
||||
|
||||
if (confirmationResult.success) {
|
||||
console.log(
|
||||
`Cancellation confirmation email sent to ${cancelledBy}: ${confirmationRecipient}`
|
||||
);
|
||||
logger.info("Cancellation confirmation email sent", {
|
||||
cancelledBy,
|
||||
email: confirmationRecipient,
|
||||
});
|
||||
results.confirmationEmailSent = true;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`Failed to send cancellation confirmation email to ${cancelledBy}:`,
|
||||
error.message
|
||||
);
|
||||
logger.error("Failed to send cancellation confirmation email", {
|
||||
cancelledBy,
|
||||
error,
|
||||
});
|
||||
}
|
||||
|
||||
// Send notification email to other party
|
||||
@@ -860,21 +851,17 @@ class RentalFlowEmailService {
|
||||
);
|
||||
|
||||
if (notificationResult.success) {
|
||||
console.log(
|
||||
`Cancellation notification email sent to ${
|
||||
cancelledBy === "owner" ? "renter" : "owner"
|
||||
}: ${notificationRecipient}`
|
||||
);
|
||||
logger.info("Cancellation notification email sent", {
|
||||
recipientType: cancelledBy === "owner" ? "renter" : "owner",
|
||||
email: notificationRecipient,
|
||||
});
|
||||
results.notificationEmailSent = true;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`Failed to send cancellation notification email:`,
|
||||
error.message
|
||||
);
|
||||
logger.error("Failed to send cancellation notification email", { error });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error sending cancellation emails:", error);
|
||||
logger.error("Error sending cancellation emails", { error });
|
||||
}
|
||||
|
||||
return results;
|
||||
@@ -991,15 +978,13 @@ class RentalFlowEmailService {
|
||||
);
|
||||
|
||||
if (renterResult.success) {
|
||||
console.log(
|
||||
`Rental completion thank you email sent to renter: ${renter.email}`
|
||||
);
|
||||
logger.info("Rental completion thank you email sent to renter", { email: renter.email });
|
||||
results.renterEmailSent = true;
|
||||
} else {
|
||||
console.error(
|
||||
`Failed to send rental completion email to renter (${renter.email}):`,
|
||||
renterResult.error
|
||||
);
|
||||
logger.error("Failed to send rental completion email to renter", {
|
||||
email: renter.email,
|
||||
error: renterResult.error,
|
||||
});
|
||||
}
|
||||
} catch (emailError) {
|
||||
logger.error("Failed to send rental completion email to renter", {
|
||||
@@ -1111,15 +1096,13 @@ class RentalFlowEmailService {
|
||||
);
|
||||
|
||||
if (ownerResult.success) {
|
||||
console.log(
|
||||
`Rental completion congratulations email sent to owner: ${owner.email}`
|
||||
);
|
||||
logger.info("Rental completion congratulations email sent to owner", { email: owner.email });
|
||||
results.ownerEmailSent = true;
|
||||
} else {
|
||||
console.error(
|
||||
`Failed to send rental completion email to owner (${owner.email}):`,
|
||||
ownerResult.error
|
||||
);
|
||||
logger.error("Failed to send rental completion email to owner", {
|
||||
email: owner.email,
|
||||
error: ownerResult.error,
|
||||
});
|
||||
}
|
||||
} catch (emailError) {
|
||||
logger.error("Failed to send rental completion email to owner", {
|
||||
@@ -1205,7 +1188,7 @@ class RentalFlowEmailService {
|
||||
htmlContent
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Failed to send payout received email:", error);
|
||||
logger.error("Failed to send payout received email", { error });
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
}
|
||||
@@ -1249,7 +1232,7 @@ class RentalFlowEmailService {
|
||||
htmlContent
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Failed to send authentication required email:", error);
|
||||
logger.error("Failed to send authentication required email", { error });
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user