use logger for console logs

integromat-app^2
aar2dee2 2023-08-31 15:49:15 +05:30
parent a236ecad02
commit bb29b2070f
1 changed files with 8 additions and 5 deletions

View File

@ -4,11 +4,14 @@ import { v4 } from "uuid";
import { getHumanReadableLocationValue } from "@calcom/core/location"; import { getHumanReadableLocationValue } from "@calcom/core/location";
import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses"; import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses";
import logger from "@calcom/lib/logger";
import { getTranslation } from "@calcom/lib/server"; import { getTranslation } from "@calcom/lib/server";
import prisma from "@calcom/prisma"; import prisma from "@calcom/prisma";
import type { ApiKey } from "@calcom/prisma/client"; import type { ApiKey } from "@calcom/prisma/client";
import { BookingStatus, WebhookTriggerEvents } from "@calcom/prisma/enums"; import { BookingStatus, WebhookTriggerEvents } from "@calcom/prisma/enums";
const log = logger.getChildLogger({ prefix: ["[node-scheduler]"] });
export async function addSubscription({ export async function addSubscription({
appApiKey, appApiKey,
triggerEvent, triggerEvent,
@ -58,7 +61,7 @@ export async function addSubscription({
return createSubscription; return createSubscription;
} catch (error) { } catch (error) {
return console.error( return log.error(
`Error creating subscription for user ${appApiKey.userId} and appId ${appApiKey.appId}.` `Error creating subscription for user ${appApiKey.userId} and appId ${appApiKey.appId}.`
); );
} }
@ -117,7 +120,7 @@ export async function deleteSubscription({
} }
return deleteWebhook; return deleteWebhook;
} catch (err) { } catch (err) {
return console.error( return log.error(
`Error deleting subscription for user ${appApiKey.userId}, webhookId ${webhookId}, appId ${appId}` `Error deleting subscription for user ${appApiKey.userId}, webhookId ${webhookId}, appId ${appId}`
); );
} }
@ -196,7 +199,7 @@ export async function listBookings(appApiKey: ApiKey) {
return updatedBookings; return updatedBookings;
} catch (err) { } catch (err) {
return console.error( return log.error(
`Error retrieving list of bookings for user ${appApiKey.userId} and appId ${appApiKey.appId}.` `Error retrieving list of bookings for user ${appApiKey.userId} and appId ${appApiKey.appId}.`
); );
} }
@ -248,7 +251,7 @@ export async function scheduleTrigger(
}, },
}); });
} catch (error) { } catch (error) {
console.error("Error cancelling scheduled jobs", error); log.error("Error cancelling scheduled jobs", error);
} }
} }
@ -291,6 +294,6 @@ export async function cancelScheduledJobs(
try { try {
await Promise.all(promises); await Promise.all(promises);
} catch (error) { } catch (error) {
console.error("Error cancelling scheduled jobs", error); log.error("Error cancelling scheduled jobs", error);
} }
} }