MCPcopy Index your code
hub / github.com/codeaashu/claude-code / cleanupOldDebugLogs

Function cleanupOldDebugLogs

src/utils/cleanup.ts:396–429  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

394 * and accumulate indefinitely without this cleanup.
395 */
396export async function cleanupOldDebugLogs(): Promise<CleanupResult> {
397 const cutoffDate = getCutoffDate()
398 const result: CleanupResult = { messages: 0, errors: 0 }
399 const fsImpl = getFsImplementation()
400 const debugDir = join(getClaudeConfigHomeDir(), 'debug')
401
402 let dirents
403 try {
404 dirents = await fsImpl.readdir(debugDir)
405 } catch {
406 return result
407 }
408
409 for (const dirent of dirents) {
410 // Preserve the 'latest' symlink
411 if (
412 !dirent.isFile() ||
413 !dirent.name.endsWith('.txt') ||
414 dirent.name === 'latest'
415 ) {
416 continue
417 }
418 try {
419 if (await unlinkIfOld(join(debugDir, dirent.name), cutoffDate, fsImpl)) {
420 result.messages++
421 }
422 } catch {
423 result.errors++
424 }
425 }
426
427 // Intentionally do NOT remove debugDir even if empty — needed for future logs
428 return result
429}
430
431const ONE_DAY_MS = 24 * 60 * 60 * 1000
432

Callers 1

Calls 3

getCutoffDateFunction · 0.85
getFsImplementationFunction · 0.85
unlinkIfOldFunction · 0.85

Tested by

no test coverage detected