Skip to content

Scheduling infrastructure for absolutely everyone.

fix: replace console logging with logger across services and features (#26127)

Kartik Labhshetwar96f8a89efa4a
diff --git a/packages/app-store/locations.ts b/packages/app-store/locations.ts
index c5504a236b5..366827f687f 100644
--- a/packages/app-store/locations.ts
+++ b/packages/app-store/locations.ts
@@ -373,7 +373,7 @@ export const locationKeyToString = (location: LocationObject) => {
}
const defaultValueVariable = eventLocationType.defaultValueVariable;
if (!defaultValueVariable) {
- console.error(`defaultValueVariable not set for ${location.type}`);
+ logger.error(`defaultValueVariable not set for ${location.type}`);
return "";
}
return location[defaultValueVariable] || eventLocationType.label;
@@ -430,12 +430,12 @@ export const getEventLocationValue = (eventLocations: LocationObject[], bookingL
}
const defaultValueVariable = eventLocationType.defaultValueVariable;
if (!defaultValueVariable) {
- console.error(`${defaultValueVariable} not set for ${bookingLocation.type}`);
+ logger.error(`${defaultValueVariable} not set for ${bookingLocation.type}`);
return "";
}
const eventLocation = getEventLocationWithType(eventLocations, bookingLocation?.type);
if (!eventLocation) {
- console.error(`Could not find eventLocation for ${bookingLocation}`);
+ logger.error(`Could not find eventLocation for ${bookingLocation}`);
return "";
}
diff --git a/packages/features/crmManager/crmManager.ts b/packages/features/crmManager/crmManager.ts
index 9bb6bcfbbf3..69aed5e526b 100644
--- a/packages/features/crmManager/crmManager.ts
+++ b/packages/features/crmManager/crmManager.ts
@@ -20,7 +20,6 @@ export default class CrmManager {
this.crmService = crmService;
if (!this.crmService) {
- console.log("💀 Error initializing CRM service");
log.error("CRM service initialization failed");
}
diff --git a/packages/features/tasker/internal-tasker.ts b/packages/features/tasker/internal-tasker.ts
index cc357f1bad4..e6a887ee1b8 100644
--- a/packages/features/tasker/internal-tasker.ts
+++ b/packages/features/tasker/internal-tasker.ts
@@ -1,3 +1,5 @@
+import logger from "@calcom/lib/logger";
+
import { Task } from "./repository";
import type { TaskTypes } from "./tasker";
import { type TaskerCreate, type Tasker } from "./tasker";
@@ -16,7 +18,7 @@ export class InternalTasker implements Tasker {
async cleanup(): Promise<void> {
const count = await Task.cleanup();
- console.info(`Cleaned up ${count} tasks`);
+ logger.info(`Cleaned up ${count} tasks`);
}
async cancel(id: string): Promise<string> {
diff --git a/packages/lib/CalendarService.ts b/packages/lib/CalendarService.ts
index ec090504df0..52d4bca2df6 100644
--- a/packages/lib/CalendarService.ts
+++ b/packages/lib/CalendarService.ts
@@ -352,7 +352,7 @@ export default abstract class BaseCalendarService implements Calendar {
const allowedExtensions = ["eml", "ics"];
const urlExtension = getFileExtension(url);
if (!allowedExtensions.includes(urlExtension)) {
- console.error(`Unsupported calendar object format: ${urlExtension}`);
+ logger.error(`Unsupported calendar object format: ${urlExtension}`);
return false;
}
return true;
@@ -383,7 +383,7 @@ export default abstract class BaseCalendarService implements Calendar {
const jcalData = ICAL.parse(sanitizeCalendarObject(object));
vcalendar = new ICAL.Component(jcalData);
} catch (e) {
- console.error("Error parsing calendar object: ", e);
+ logger.error("Error parsing calendar object: ", e);
return;
}
const vevents = vcalendar.getAllSubcomponents("vevent");
@@ -424,10 +424,10 @@ export default abstract class BaseCalendarService implements Calendar {
vcalendar.addSubcomponent(timezoneComp);
} catch (e) {
// Adds try-catch to ensure the code proceeds when Apple Calendar provides non-standard TZIDs
- console.log("error in adding vtimezone", e);
+ logger.warn("error in adding vtimezone", e);
}
} else {
- console.error("No timezone found");
+ logger.warn("No timezone found");
}
}
@@ -447,7 +447,7 @@ export default abstract class BaseCalendarService implements Calendar {
if (event.isRecurring()) {
let maxIterations = 365;
if (["HOURLY", "SECONDLY", "MINUTELY"].includes(event.getRecurrenceTypes())) {
- console.error(`Won't handle [${event.getRecurrenceTypes()}] recurrence`);
+ logger.warn(`Won't handle [${event.getRecurrenceTypes()}] recurrence`);
return;
}
@@ -500,7 +500,7 @@ export default abstract class BaseCalendarService implements Calendar {
}
}
if (maxIterations <= 0) {
- console.warn("could not find any occurrence for recurring event in 365 iterations");
+ logger.warn("Could not find any occurrence for recurring event in 365 iterations");
}
return;
}
@@ -700,7 +700,7 @@ export default abstract class BaseCalendarService implements Calendar {
});
return events;
} catch (reason) {
- console.error(reason);
+ logger.error(reason);
throw reason;
}
}
diff --git a/packages/lib/getIP.ts b/packages/lib/getIP.ts
index 6b26c971ee1..cf1c03ace11 100644
--- a/packages/lib/getIP.ts
+++ b/packages/lib/getIP.ts
@@ -1,6 +1,8 @@
import type { NextApiRequest } from "next";
import z from "zod";
+import logger from "./logger";
+
export function parseIpFromHeaders(value: string | string[]) {
return Array.isArray(value) ? value[0] : value.split(",")[0];
}
@@ -29,7 +31,7 @@ export function isIpInBanlist(request: Request | NextApiRequest) {
const rawBanListJson = process.env.IP_BANLIST || "[]";
const banList = banlistSchema.parse(JSON.parse(rawBanListJson));
if (banList.includes(IP)) {
- console.log(`Found banned IP: ${IP} in IP_BANLIST`);
+ logger.warn(`Found banned IP: ${IP} in IP_BANLIST`);
return true;
}
return false;
@@ -39,7 +41,7 @@ export function isIpInBanListString(identifer: string) {
const rawBanListJson = process.env.IP_BANLIST || "[]";
const banList = banlistSchema.parse(JSON.parse(rawBanListJson));
if (banList.includes(identifer)) {
- console.log(`Found banned IP: ${identifer} in IP_BANLIST`);
+ logger.warn(`Found banned IP: ${identifer} in IP_BANLIST`);
return true;
}
return false;
diff --git a/packages/lib/perf.ts b/packages/lib/perf.ts
index 905d83ffa39..ffa44e70e94 100644
--- a/packages/lib/perf.ts
+++ b/packages/lib/perf.ts
@@ -1,8 +1,10 @@
+import logger from "./logger";
+
export const logP = (message: string) => {
const start = performance.now();
return () => {
const end = performance.now();
- console.log(`[PERF]: ${message} took ${end - start}ms`);
+ logger.debug(`[PERF]: ${message} took ${end - start}ms`);
};
};