@@ -17,9 +17,8 @@ import type {
17
17
NetlifyIncrementalCacheValue ,
18
18
} from '../../shared/cache-types.cjs'
19
19
import { getRegionalBlobStore } from '../regional-blob-store.cjs'
20
- import { logger } from '../systemlog.cjs'
21
20
22
- import { getRequestContext } from './request-context.cjs'
21
+ import { getLogger , getRequestContext } from './request-context.cjs'
23
22
import { getTracer } from './tracer.cjs'
24
23
25
24
type TagManifest = { revalidatedAt : number }
@@ -109,7 +108,7 @@ export class NetlifyCacheHandler implements CacheHandler {
109
108
async get ( ...args : Parameters < CacheHandler [ 'get' ] > ) : ReturnType < CacheHandler [ 'get' ] > {
110
109
return this . tracer . withActiveSpan ( 'get cache key' , async ( span ) => {
111
110
const [ key , ctx = { } ] = args
112
- logger . debug ( `[NetlifyCacheHandler.get]: ${ key } ` )
111
+ getLogger ( ) . debug ( `[NetlifyCacheHandler.get]: ${ key } ` )
113
112
114
113
const blobKey = await this . encodeBlobKey ( key )
115
114
span . setAttributes ( { key, blobKey } )
@@ -177,7 +176,7 @@ export class NetlifyCacheHandler implements CacheHandler {
177
176
const lastModified = Date . now ( )
178
177
span . setAttributes ( { key, lastModified, blobKey } )
179
178
180
- logger . debug ( `[NetlifyCacheHandler.set]: ${ key } ` )
179
+ getLogger ( ) . debug ( `[NetlifyCacheHandler.set]: ${ key } ` )
181
180
182
181
const value : NetlifyIncrementalCacheValue | null =
183
182
data ?. kind === 'ROUTE'
@@ -198,10 +197,10 @@ export class NetlifyCacheHandler implements CacheHandler {
198
197
const requestContext = getRequestContext ( )
199
198
if ( requestContext ?. didPagesRouterOnDemandRevalidate ) {
200
199
const tag = `_N_T_${ key === '/index' ? '/' : key } `
201
- logger . debug ( `Purging CDN cache for: [${ tag } ]` )
200
+ getLogger ( ) . debug ( `Purging CDN cache for: [${ tag } ]` )
202
201
purgeCache ( { tags : [ tag ] } ) . catch ( ( error ) => {
203
202
// TODO: add reporting here
204
- logger
203
+ getLogger ( )
205
204
. withError ( error )
206
205
. error ( `[NetlifyCacheHandler]: Purging the cache for tag ${ tag } failed` )
207
206
} )
@@ -212,7 +211,7 @@ export class NetlifyCacheHandler implements CacheHandler {
212
211
213
212
// eslint-disable-next-line @typescript-eslint/no-explicit-any
214
213
async revalidateTag ( tagOrTags : string | string [ ] , ...args : any ) {
215
- logger . withFields ( { tagOrTags, args } ) . debug ( 'NetlifyCacheHandler.revalidateTag' )
214
+ getLogger ( ) . withFields ( { tagOrTags, args } ) . debug ( 'NetlifyCacheHandler.revalidateTag' )
216
215
217
216
const tags = Array . isArray ( tagOrTags ) ? tagOrTags : [ tagOrTags ]
218
217
@@ -225,14 +224,14 @@ export class NetlifyCacheHandler implements CacheHandler {
225
224
try {
226
225
await this . blobStore . setJSON ( await this . encodeBlobKey ( tag ) , data )
227
226
} catch ( error ) {
228
- logger . withError ( error ) . log ( `Failed to update tag manifest for ${ tag } ` )
227
+ getLogger ( ) . withError ( error ) . log ( `Failed to update tag manifest for ${ tag } ` )
229
228
}
230
229
} ) ,
231
230
)
232
231
233
232
purgeCache ( { tags } ) . catch ( ( error ) => {
234
233
// TODO: add reporting here
235
- logger
234
+ getLogger ( )
236
235
. withError ( error )
237
236
. error ( `[NetlifyCacheHandler]: Purging the cache for tags ${ tags . join ( ', ' ) } failed` )
238
237
} )
0 commit comments