chore: improve logs (#12467)
* chore: improve logs * fix: import * chore: use safe stringify * chore: add more logs to google calendar * chore: use this.log --------- Co-authored-by: sean-brydon <[email protected]>
This commit is contained in:
1 parent
6c4b1154b8
commit
7dc6df2ad6
10 files changed
+53
-20
No files matched your search
@@ -3,6 +3,7 @@ import { getWebhookPayloadForBooking } from "@calcom/features/bookings/lib/getWe
|
||||
import getWebhooks from "@calcom/features/webhooks/lib/getWebhooks";
|
||||
import sendPayload from "@calcom/features/webhooks/lib/sendPayload";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { safeStringify } from "@calcom/lib/safeStringify";
|
||||
import { WebhookTriggerEvents } from "@calcom/prisma/enums";
|
||||
import type { CalendarEvent } from "@calcom/types/Calendar";
|
||||
|
||||
@@ -65,6 +66,6 @@ export async function handleBookingRequested(args: {
|
||||
await Promise.all(promises);
|
||||
} catch (error) {
|
||||
// Silently fail
|
||||
log.error(error);
|
||||
log.error("Error in handleBookingRequested", safeStringify(error));
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import type { EventTypeInfo } from "@calcom/features/webhooks/lib/sendPayload";
|
||||
import sendPayload from "@calcom/features/webhooks/lib/sendPayload";
|
||||
import { getTeamIdFromEventType } from "@calcom/lib/getTeamIdFromEventType";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { safeStringify } from "@calcom/lib/safeStringify";
|
||||
import type { PrismaClient } from "@calcom/prisma";
|
||||
import { BookingStatus, WebhookTriggerEvents } from "@calcom/prisma/enums";
|
||||
import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
|
||||
@@ -65,7 +66,7 @@ export async function handleConfirmation(args: {
|
||||
message: "Booking failed",
|
||||
};
|
||||
|
||||
log.error(`Booking ${user.username} failed`, JSON.stringify({ error, results }));
|
||||
log.error(`Booking ${user.username} failed`, safeStringify({ error, results }));
|
||||
} else {
|
||||
if (results.length) {
|
||||
// TODO: Handle created event metadata more elegantly
|
||||
|
||||
@@ -14,6 +14,7 @@ import { HttpError as HttpCode } from "@calcom/lib/http-error";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { getBooking } from "@calcom/lib/payment/getBooking";
|
||||
import { handlePaymentSuccess } from "@calcom/lib/payment/handlePaymentSuccess";
|
||||
import { safeStringify } from "@calcom/lib/safeStringify";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
import { BookingStatus } from "@calcom/prisma/enums";
|
||||
|
||||
@@ -38,7 +39,7 @@ export async function handleStripePaymentSuccess(event: Stripe.Event) {
|
||||
});
|
||||
|
||||
if (!payment?.bookingId) {
|
||||
log.error(JSON.stringify(paymentIntent), JSON.stringify(payment));
|
||||
log.error("Stripe: Payment Not Found", safeStringify(paymentIntent), safeStringify(payment));
|
||||
throw new HttpCode({ statusCode: 204, message: "Payment not found" });
|
||||
}
|
||||
if (!payment?.bookingId) throw new HttpCode({ statusCode: 204, message: "Payment not found" });
|
||||
|
||||
@@ -4,6 +4,7 @@ import { v4 } from "uuid";
|
||||
import { getHumanReadableLocationValue } from "@calcom/core/location";
|
||||
import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { safeStringify } from "@calcom/lib/safeStringify";
|
||||
import { getTranslation } from "@calcom/lib/server";
|
||||
import prisma from "@calcom/prisma";
|
||||
import type { ApiKey } from "@calcom/prisma/client";
|
||||
@@ -75,7 +76,10 @@ export async function addSubscription({
|
||||
const userId = appApiKey ? appApiKey.userId : account && !account.isTeam ? account.id : null;
|
||||
const teamId = appApiKey ? appApiKey.teamId : account && account.isTeam ? account.id : null;
|
||||
|
||||
log.error(`Error creating subscription for ${teamId ? `team ${teamId}` : `user ${userId}`}.`);
|
||||
log.error(
|
||||
`Error creating subscription for ${teamId ? `team ${teamId}` : `user ${userId}`}.`,
|
||||
safeStringify(error)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +161,8 @@ export async function deleteSubscription({
|
||||
log.error(
|
||||
`Error deleting subscription for user ${
|
||||
teamId ? `team ${teamId}` : `userId ${userId}`
|
||||
}, webhookId ${webhookId}`
|
||||
}, webhookId ${webhookId}`,
|
||||
safeStringify(err)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -260,7 +265,10 @@ export async function listBookings(
|
||||
const userId = appApiKey ? appApiKey.userId : account && !account.isTeam ? account.id : null;
|
||||
const teamId = appApiKey ? appApiKey.teamId : account && account.isTeam ? account.id : null;
|
||||
|
||||
log.error(`Error retrieving list of bookings for ${teamId ? `team ${teamId}` : `user ${userId}`}.`);
|
||||
log.error(
|
||||
`Error retrieving list of bookings for ${teamId ? `team ${teamId}` : `user ${userId}`}.`,
|
||||
safeStringify(err)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user