Abhishek
Abhishek7mo ago

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);
}
}
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
23 Replies
Abhishek
AbhishekOP7mo ago
My console.log is not all showing in dev logs
ballingt
ballingt7mo ago
@Abhishek do you see anything in dev logs? In the browser logs are shown in dev, not prod. Where are you looking for these errors, in the Convex dashboard? In the terminal?
Abhishek
AbhishekOP7mo ago
@ballingt so if i put console log in convex function then the logs should show in dev log of the dashboard right ?
ballingt
ballingt7mo ago
Yes, like this
No description
Abhishek
AbhishekOP7mo ago
exactly but its not showing in my case
ballingt
ballingt7mo ago
Does the "success" log entry show up?
Abhishek
AbhishekOP7mo ago
yes console log is not showing but conseloe debuge is showing
ballingt
ballingt7mo ago
console.debug?
Abhishek
AbhishekOP7mo ago
yes that show up
ballingt
ballingt7mo ago
Do you have any filters active?
No description
Abhishek
AbhishekOP7mo ago
No description
Abhishek
AbhishekOP7mo ago
yes first thing i checked
ballingt
ballingt7mo ago
Could you try this with a custom function in the funtion runner?
Abhishek
AbhishekOP7mo ago
sure one sec
ballingt
ballingt7mo ago
Wondering if it's specific to one function or for your whole deployment
Abhishek
AbhishekOP7mo ago
No description
Abhishek
AbhishekOP7mo ago
yes showing up for custom function but for prod env logs are coming up fine
ballingt
ballingt7mo ago
Could you try adding a simple console.log to the top of the function where you are seeing this, like console.log('hello')? oh or actually
console.log('hello');
await new Promise((r) => setTimeout(r, 1000));
console.log('hello');
await new Promise((r) => setTimeout(r, 1000));
Abhishek
AbhishekOP7mo ago
@ballingt figured it out its function issue
ballingt
ballingt7mo ago
say more, I'm very curious
Abhishek
AbhishekOP7mo ago
just tested it , there was few if else caseses due to which flow was not going to console log whereas the in prod case the if else flow is diffrent Thanks @ballingt
ballingt
ballingt7mo ago
ah ok, so there's nothing wrong? sounds good
Abhishek
AbhishekOP7mo ago
nope nothing is wrong just suffer with time and date XD

Did you find this page helpful?