AbhishekA
Convex Community2y ago
33 replies
Abhishek

Logs are different for dev and prod

I am experiencing a bug related to the new Date () but the issue is logs are not at all showing in dev env but the error log is showing in prod.

export function convertTimeToUTC(
  startDate: string,
  time: string,
  timezone: string,
) {
  const formatString = "yyyy-MM-dd hh:mm a";

  const parsedTime = parse(time, "h:mm a", new Date());
  const formattedTime = format(parsedTime, "HH:mm:ss");

  console.debug(
    "API Logs | Time and start date and timezon of the user: ",
    time,
    startDate,
    timezone,
  );

  const parsedDate = parse(
    `${startDate} ${time}`,
    formatString,
    new Date(),
  ).toLocaleString();

  console.log("API Logs | Parsed time and start date : ", parsedDate);
  try {
    const utcTime = zonedTimeToUtc(`${startDate} ${formattedTime}`, timezone);
    console.log("API Logs | Time in UTC  : ", utcTime.toLocaleString());
    console.log("API Logs | Time in UTC sent to cron : ", utcTime);
    return utcTime;
  } catch (error) {
    console.error("API Logs | Error in converting time to UTC", error);
  }
}


So this function is throwing an error but the error is not coming in dev environments logs but showing up in prod logs
Was this page helpful?