Remove temporary debug logging from formatLocalTime and HeartbeatPopup in UptimeStatusIsland
- Cleaned up console logs used for production debugging to streamline the code. - Added a log statement to indicate when UptimeStatusIsland is loaded in production. - Maintained existing functionality while improving code clarity.
This commit is contained in:
@@ -48,27 +48,22 @@ function getUptime24hBg(uptime) {
|
|||||||
function formatLocalTime(rawTime, zone = 'utc') {
|
function formatLocalTime(rawTime, zone = 'utc') {
|
||||||
if (!rawTime) return '';
|
if (!rawTime) return '';
|
||||||
|
|
||||||
// Temporary production debug logging
|
|
||||||
console.log('PROD DEBUG - Raw time:', rawTime, 'Zone:', zone);
|
|
||||||
|
|
||||||
let dt = null;
|
let dt = null;
|
||||||
|
|
||||||
// First try ISO parsing (most reliable for UTC timestamps)
|
// First try ISO parsing (most reliable for UTC timestamps)
|
||||||
try {
|
try {
|
||||||
dt = DateTime.fromISO(rawTime, { zone: 'utc' });
|
dt = DateTime.fromISO(rawTime, { zone: 'utc' });
|
||||||
if (dt.isValid) {
|
if (dt.isValid) {
|
||||||
console.log('PROD DEBUG - ISO parsing successful:', dt.toISO());
|
|
||||||
// If target zone is UTC, return as-is
|
// If target zone is UTC, return as-is
|
||||||
if (zone === 'utc') {
|
if (zone === 'utc') {
|
||||||
return dt.toFormat('dd-MM-yyyy, HH:mm:ss');
|
return dt.toFormat('dd-MM-yyyy, HH:mm:ss');
|
||||||
}
|
}
|
||||||
// Otherwise convert to target timezone
|
// Otherwise convert to target timezone
|
||||||
const converted = dt.setZone(zone);
|
const converted = dt.setZone(zone);
|
||||||
console.log('PROD DEBUG - Converted to zone:', converted.toISO());
|
|
||||||
return converted.isValid ? converted.toFormat('dd-MM-yyyy, HH:mm:ss') : 'Invalid DateTime';
|
return converted.isValid ? converted.toFormat('dd-MM-yyyy, HH:mm:ss') : 'Invalid DateTime';
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('PROD DEBUG - ISO parsing failed:', e.message);
|
// Continue to format parsing if ISO fails
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try various formats, always assuming incoming time is UTC
|
// Try various formats, always assuming incoming time is UTC
|
||||||
@@ -84,10 +79,7 @@ function formatLocalTime(rawTime, zone = 'utc') {
|
|||||||
for (const format of formats) {
|
for (const format of formats) {
|
||||||
try {
|
try {
|
||||||
dt = DateTime.fromFormat(rawTime, format, { zone: 'utc' });
|
dt = DateTime.fromFormat(rawTime, format, { zone: 'utc' });
|
||||||
if (dt.isValid) {
|
if (dt.isValid) break;
|
||||||
console.log('PROD DEBUG - Format parsing successful:', format, dt.toISO());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -99,15 +91,13 @@ function formatLocalTime(rawTime, zone = 'utc') {
|
|||||||
const jsDate = new Date(rawTime);
|
const jsDate = new Date(rawTime);
|
||||||
if (!isNaN(jsDate.getTime())) {
|
if (!isNaN(jsDate.getTime())) {
|
||||||
dt = DateTime.fromJSDate(jsDate, { zone: 'utc' });
|
dt = DateTime.fromJSDate(jsDate, { zone: 'utc' });
|
||||||
console.log('PROD DEBUG - JS Date parsing successful:', dt.toISO());
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('PROD DEBUG - JS Date parsing failed:', e.message);
|
// Give up
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dt || !dt.isValid) {
|
if (!dt || !dt.isValid) {
|
||||||
console.log('PROD DEBUG - All parsing failed for:', rawTime);
|
|
||||||
return 'Invalid DateTime';
|
return 'Invalid DateTime';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,14 +111,9 @@ function formatLocalTime(rawTime, zone = 'utc') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function HeartbeatPopup({ hb, userZone, monitor }) {
|
function HeartbeatPopup({ hb, userZone, monitor }) {
|
||||||
// Debug logging to see what data we're receiving
|
|
||||||
console.log('HeartbeatPopup PROD DEBUG:', { hb, userZone, hasTime: !!hb?.time });
|
|
||||||
|
|
||||||
const localTime = hb ? formatLocalTime(hb.time, userZone) : '';
|
const localTime = hb ? formatLocalTime(hb.time, userZone) : '';
|
||||||
const utcTime = hb ? formatLocalTime(hb.time, 'utc') : '';
|
const utcTime = hb ? formatLocalTime(hb.time, 'utc') : '';
|
||||||
|
|
||||||
console.log('HeartbeatPopup PROD DEBUG - Results:', { localTime, utcTime });
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ minWidth: 220 }}>
|
<div style={{ minWidth: 220 }}>
|
||||||
<div style={{ display: 'flex', alignItems: 'center', marginBottom: 4 }}>
|
<div style={{ display: 'flex', alignItems: 'center', marginBottom: 4 }}>
|
||||||
@@ -160,6 +145,7 @@ function HeartbeatPopup({ hb, userZone, monitor }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function UptimeStatusIsland() {
|
export default function UptimeStatusIsland() {
|
||||||
|
console.log('UptimeStatusIsland loaded in production');
|
||||||
const [data, setData] = useState(null);
|
const [data, setData] = useState(null);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState(null);
|
const [error, setError] = useState(null);
|
||||||
|
Reference in New Issue
Block a user