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

Co-authored-by: Dhairyashil Shinde <[email protected]>
This commit is contained in:
Kartik LabhshetwarandDhairyashil Shinde authored and GitHub committed 2025-12-23 08:24:23 +00:00
1 parent a2cb529d62
commit 96f8a89efa
6 files changed
+20 -15

No files matched your search

+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`);
};
};