Skip to content

Commit 44a1bb9

Browse files
committed
v0:ref: enhance logging in read processor for cache
1 parent 55fee00 commit 44a1bb9

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

apps/workers/v0/src/routers/read/read.processor.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import type { ORPCContext } from '@/lib/context';
1515
import { formatDuration } from '@/utils/formater';
1616
import { getReadCacheKey } from '@/utils/kv/read-kv-key';
1717
import { kvPutWithRetry } from '@/utils/kv/retry';
18-
import { logError } from '@/utils/loggers';
18+
import { logDebug, logError } from '@/utils/loggers';
1919
import {
2020
fixCodeBlockFormatting,
2121
processMultiLineLinks,
@@ -161,6 +161,13 @@ export async function processReadRequest(
161161
cacheOptions,
162162
} = params;
163163

164+
console.log(
165+
'🚀 ~ processReadRequest ~ params',
166+
JSON.stringify(params, null, 2),
167+
'isGETRequest',
168+
isGETRequest,
169+
);
170+
164171
let readResponse: ReadResponse | undefined;
165172
// Initialize cache flag
166173
let isReadCacheFresh = false;
@@ -195,6 +202,10 @@ export async function processReadRequest(
195202
const oneDayAgo = Date.now() - DEFAULT_KV_CACHE_EXPIRATION_TTL * 1000; // 1 day in milliseconds
196203

197204
if (cacheTimestamp > oneDayAgo) {
205+
logDebug(
206+
`💽 [READ Endpoint] Found fresh cached read response in KV for ${targetUrl}`,
207+
);
208+
198209
isReadCacheFresh = true;
199210

200211
if (isGETRequest) {
@@ -319,6 +330,10 @@ export async function processReadRequest(
319330
},
320331
},
321332
);
333+
334+
logDebug(
335+
`💽 [READ Endpoint] Updated read response in KV cache for ${targetUrl}`,
336+
);
322337
} catch (error) {
323338
logError('[ERROR] Read processor cache write error:', error);
324339
// Continue without caching if write fails

0 commit comments

Comments
 (0)