diff --git a/packages/server/modules/shared/utils/caching.ts b/packages/server/modules/shared/utils/caching.ts index 66115b5df..aa22adf5f 100644 --- a/packages/server/modules/shared/utils/caching.ts +++ b/packages/server/modules/shared/utils/caching.ts @@ -51,6 +51,10 @@ type WrapWithCacheBaseParams> = { * Default: true */ cachePromises?: boolean + /** + * Logger log level. Defaults to 'debug' + */ + logLevel?: 'info' | 'debug' }> } @@ -67,6 +71,7 @@ export const wrapWithCache = , Results>( const cachePromises = params.options?.cachePromises ?? true const { argsKey = (...args: Args) => JSON.stringify(args) } = options || {} const key = (...args: Args) => `wrapWithCache:${name}:${argsKey(...args)}` + const logLevel = options?.logLevel || 'debug' const buildResolver = ( @@ -84,14 +89,14 @@ export const wrapWithCache = , Results>( }) if (skipCache) { - logger.info("Cache '{cacheName}' skipped for specific args") + logger[logLevel]("Cache '{cacheName}' skipped for specific args") } else { const cached = await cacheProvider.get(cacheKey) if (cached !== undefined) { - logger.info("Cache '{cacheName}' hit for specific args") + logger[logLevel]("Cache '{cacheName}' hit for specific args") return cached as Results } else { - logger.info("Cache '{cacheName}' miss for specific args") + logger[logLevel]("Cache '{cacheName}' miss for specific args") } } @@ -139,7 +144,7 @@ export const wrapWithCache = , Results>( const logger = (getRequestLogger() || cacheLogger).child({ cacheName: name }) await cacheProvider.delete(cacheKey) - logger.info("Cache '{cacheName}' cleared for specific args") + logger[logLevel]("Cache '{cacheName}' cleared for specific args") } ret.fresh = freshResolver