From 96f8a89efa4a251af235bcfac72d73805cb195e3 Mon Sep 17 00:00:00 2001 From: Kartik Labhshetwar Date: Tue, 23 Dec 2025 13:54:23 +0530 Subject: [PATCH] fix: replace console logging with logger across services and features (#26127) Co-authored-by: Dhairyashil Shinde <93669429+dhairyashiil@users.noreply.github.com> --- packages/app-store/locations.ts | 6 +++--- packages/features/crmManager/crmManager.ts | 1 - packages/features/tasker/internal-tasker.ts | 4 +++- packages/lib/CalendarService.ts | 14 +++++++------- packages/lib/getIP.ts | 6 ++++-- packages/lib/perf.ts | 4 +++- 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/packages/app-store/locations.ts b/packages/app-store/locations.ts index c5504a236b..366827f687 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 9bb6bcfbbf..69aed5e526 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 cc357f1bad..e6a887ee1b 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 { const count = await Task.cleanup(); - console.info(`Cleaned up ${count} tasks`); + logger.info(`Cleaned up ${count} tasks`); } async cancel(id: string): Promise { diff --git a/packages/lib/CalendarService.ts b/packages/lib/CalendarService.ts index ec090504df..52d4bca2df 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 6b26c971ee..cf1c03ace1 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 905d83ffa3..ffa44e70e9 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`); }; };