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

Co-authored-by: Dhairyashil Shinde <93669429+dhairyashiil@users.noreply.github.com>
This commit is contained in:
Kartik Labhshetwar
2025-12-23 08:24:23 +00:00
committed by GitHub
co-authored by Dhairyashil Shinde
parent a2cb529d62
commit 96f8a89efa
6 changed files with 20 additions and 15 deletions
+3 -3
View File
@@ -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 "";
}
@@ -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");
}
+3 -1
View File
@@ -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> {
+7 -7
View File
@@ -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;
}
}
+4 -2
View File
@@ -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;
+3 -1
View File
@@ -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`);
};
};