Add logging (#21874)

This commit is contained in:
Joe Au-Yeung
2025-06-17 15:58:58 +00:00
committed by GitHub
parent 1a0ce47404
commit 3b19ede6a3
@@ -1,8 +1,11 @@
import { ErrorCode } from "@calcom/lib/errorCodes";
import { ErrorWithCode } from "@calcom/lib/errors";
import logger from "@calcom/lib/logger";
import prisma from "@calcom/prisma";
import { BookingStatus } from "@calcom/prisma/enums";
const log = logger.getSubLogger({ prefix: ["[checkActiveBookingsLimitForBooker]"] });
export const checkActiveBookingsLimitForBooker = async ({
eventTypeId,
maxActiveBookingsPerBooker,
@@ -57,6 +60,7 @@ const checkActiveBookingsLimit = async ({
});
if (bookingsCount >= maxActiveBookingsPerBooker) {
log.warn(`Maximum booking limit reached for ${bookerEmail} for event type ${eventTypeId}`);
throw new ErrorWithCode(ErrorCode.BookerLimitExceeded, ErrorCode.BookerLimitExceeded);
}
};
@@ -104,6 +108,7 @@ const checkActiveBookingsLimitAndOfferReschedule = async ({
const lastBooking = bookingsCount[bookingsCount.length - 1];
if (bookingsCount.length >= maxActiveBookingsPerBooker) {
log.warn(`Maximum booking limit reached for ${bookerEmail} for event type ${eventTypeId}`);
throw new ErrorWithCode(
ErrorCode.BookerLimitExceededReschedule,
ErrorCode.BookerLimitExceededReschedule,