Major Log Refactor & Cleanup
This commit is contained in:
@@ -33,12 +33,12 @@ function getCachedGeocode(cityQuery) {
|
||||
const cached = JSON.parse(data);
|
||||
// Verify the query matches
|
||||
if (cached.query && cached.query.toLowerCase().trim() === cityQuery.toLowerCase().trim()) {
|
||||
console.log(`Using cached geocode for: ${cityQuery}`);
|
||||
console.log(`Geocode: ${cityQuery} (cached)`);
|
||||
return cached;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(`Cache read error for ${cityQuery}:`, error.message);
|
||||
// Silent fail
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -52,9 +52,8 @@ function saveCachedGeocode(cityQuery, data) {
|
||||
try {
|
||||
const cacheFile = path.join(CACHE_DIR, getCacheFileName(cityQuery));
|
||||
fs.writeFileSync(cacheFile, JSON.stringify(data, null, 2), 'utf8');
|
||||
console.log(`Cached geocode for: ${cityQuery}`);
|
||||
} catch (error) {
|
||||
console.warn(`Cache write error for ${cityQuery}:`, error.message);
|
||||
// Silent fail
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +95,7 @@ async function geocodeCity(cityQuery) {
|
||||
lon: parseFloat(results[0].lon),
|
||||
displayName: results[0].display_name
|
||||
};
|
||||
console.log(`Geocode: ${cityQuery} -> ${geocodeResult.displayName} (API)`);
|
||||
// Save to cache
|
||||
saveCachedGeocode(cityQuery, geocodeResult);
|
||||
resolve(geocodeResult);
|
||||
|
||||
Reference in New Issue
Block a user