diff --git a/api/config/production.json b/api/config/production.json index 2c63c0851..ee8023b4e 100644 --- a/api/config/production.json +++ b/api/config/production.json @@ -1,2 +1,10 @@ { + "db": { + "logging": [ + "error", + "schema", + "info", + "log" + ] + } } diff --git a/api/src/modules/geo-coding/geo-coding.service.ts b/api/src/modules/geo-coding/geo-coding.service.ts index 3857745e6..4ca8f07cc 100644 --- a/api/src/modules/geo-coding/geo-coding.service.ts +++ b/api/src/modules/geo-coding/geo-coding.service.ts @@ -44,6 +44,9 @@ export class GeoCodingService extends GeoCodingAbstractClass { const errors: any[] = []; for (let i: number = 0; i < sourcingData.length; i++) { const location: SourcingData = sourcingData[i]; + this.logger.debug( + `Geocoding location: Country: ${location.locationCountryInput}, Address: ${location.locationAddressInput}, LAT: ${location.locationLatitude}, LONG: ${location.locationLongitude}`, + ); try { if (location.locationType === LOCATION_TYPES.UNKNOWN) { geoCodedSourcingData.push( diff --git a/api/src/modules/geo-coding/geocoders/cache.geocoder.ts b/api/src/modules/geo-coding/geocoders/cache.geocoder.ts index b72128095..18578e37c 100644 --- a/api/src/modules/geo-coding/geocoders/cache.geocoder.ts +++ b/api/src/modules/geo-coding/geocoders/cache.geocoder.ts @@ -1,4 +1,4 @@ -import { Inject } from '@nestjs/common'; +import { Inject, Logger } from '@nestjs/common'; import { CACHE_MANAGER } from '@nestjs/cache-manager'; import { GeocodeArgs, @@ -11,6 +11,8 @@ import { GoogleMapsGeocoder } from 'modules/geo-coding/geocoders/google-maps.geo export const GEOCODING_CACHE_ENABLED: unique symbol = Symbol(); export class CacheGeocoder implements GeocoderInterface { + private logger: Logger = new Logger(CacheGeocoder.name); + constructor( @Inject(GEOCODING_CACHE_ENABLED) private geocacheEnabled: boolean, @Inject(GoogleMapsGeocoder) private backendGeocoder: GeocoderInterface, @@ -27,8 +29,15 @@ export class CacheGeocoder implements GeocoderInterface { cacheKey, ); - if (cachedData) return cachedData; + if (cachedData) { + this.logger.debug( + `Cache hit for location ${args.address} ${args.latlng} `, + ); + return cachedData; + } + const data: GeocodeResponse = await this.backendGeocoder.geocode(args); + this.logger.debug('Set cache for location ' + args.address + args.latlng); await this.cacheManager.set(cacheKey, data); return data; }