@@ -17,6 +17,7 @@ import type {
1717 NetlifyIncrementalCacheValue ,
1818} from '../../shared/cache-types.cjs'
1919import { getRegionalBlobStore } from '../regional-blob-store.cjs'
20+ import { logger } from '../systemlog.cjs'
2021
2122import { getRequestContext } from './request-context.cjs'
2223import { getTracer } from './tracer.cjs'
@@ -108,7 +109,7 @@ export class NetlifyCacheHandler implements CacheHandler {
108109 async get ( ...args : Parameters < CacheHandler [ 'get' ] > ) : ReturnType < CacheHandler [ 'get' ] > {
109110 return this . tracer . withActiveSpan ( 'get cache key' , async ( span ) => {
110111 const [ key , ctx = { } ] = args
111- console . debug ( `[NetlifyCacheHandler.get]: ${ key } ` )
112+ logger . debug ( `[NetlifyCacheHandler.get]: ${ key } ` )
112113
113114 const blobKey = await this . encodeBlobKey ( key )
114115 span . setAttributes ( { key, blobKey } )
@@ -176,7 +177,7 @@ export class NetlifyCacheHandler implements CacheHandler {
176177 const lastModified = Date . now ( )
177178 span . setAttributes ( { key, lastModified, blobKey } )
178179
179- console . debug ( `[NetlifyCacheHandler.set]: ${ key } ` )
180+ logger . debug ( `[NetlifyCacheHandler.set]: ${ key } ` )
180181
181182 const value : NetlifyIncrementalCacheValue | null =
182183 data ?. kind === 'ROUTE'
@@ -197,10 +198,12 @@ export class NetlifyCacheHandler implements CacheHandler {
197198 const requestContext = getRequestContext ( )
198199 if ( requestContext ?. didPagesRouterOnDemandRevalidate ) {
199200 const tag = `_N_T_${ key === '/index' ? '/' : key } `
200- console . debug ( ' Purging CDN cache for:' , [ tag ] )
201+ logger . debug ( ` Purging CDN cache for: [ ${ tag } ]` )
201202 purgeCache ( { tags : [ tag ] } ) . catch ( ( error ) => {
202203 // TODO: add reporting here
203- console . error ( `[NetlifyCacheHandler]: Purging the cache for tag ${ tag } failed` , error )
204+ logger
205+ . withError ( error )
206+ . error ( `[NetlifyCacheHandler]: Purging the cache for tag ${ tag } failed` )
204207 } )
205208 }
206209 }
@@ -209,7 +212,7 @@ export class NetlifyCacheHandler implements CacheHandler {
209212
210213 // eslint-disable-next-line @typescript-eslint/no-explicit-any
211214 async revalidateTag ( tagOrTags : string | string [ ] , ...args : any ) {
212- console . debug ( 'NetlifyCacheHandler.revalidateTag' , tagOrTags , args )
215+ logger . withFields ( { tagOrTags , args } ) . debug ( 'NetlifyCacheHandler.revalidateTag' )
213216
214217 const tags = Array . isArray ( tagOrTags ) ? tagOrTags : [ tagOrTags ]
215218
@@ -222,17 +225,16 @@ export class NetlifyCacheHandler implements CacheHandler {
222225 try {
223226 await this . blobStore . setJSON ( await this . encodeBlobKey ( tag ) , data )
224227 } catch ( error ) {
225- console . warn ( `Failed to update tag manifest for ${ tag } ` , error )
228+ logger . withError ( error ) . log ( `Failed to update tag manifest for ${ tag } ` )
226229 }
227230 } ) ,
228231 )
229232
230233 purgeCache ( { tags } ) . catch ( ( error ) => {
231234 // TODO: add reporting here
232- console . error (
233- `[NetlifyCacheHandler]: Purging the cache for tags ${ tags . join ( ', ' ) } failed` ,
234- error ,
235- )
235+ logger
236+ . withError ( error )
237+ . error ( `[NetlifyCacheHandler]: Purging the cache for tags ${ tags . join ( ', ' ) } failed` )
236238 } )
237239 }
238240
0 commit comments