Files
claude-code/src/bridge/rcDebugLog.ts
unraid 4c409df35d chore: full Biome lint cleanup — zero errors, zero warnings
- Remove 203 unused biome-ignore suppression comments (noConsole rule is off)
- Apply all FIXABLE transforms: Math.pow->**, parseInt radix,
  noUselessContinue, noUselessUndefinedInitialization, useIndexOf,
  useRegexLiterals, useShorthandFunctionType, noPrototypeBuiltins
- Add targeted suppressions for 31 intentional patterns
- Format all src/ files via Biome (quote style, import line width)
- Result: 0 errors, 0 warnings across 2649 files
2026-04-14 19:56:13 +08:00

43 lines
1.1 KiB
TypeScript

/**
* File-based debug logger for Remote Control bridge diagnostics.
* Writes [RC-DEBUG] lines to ~/.claude/rc-debug.log so they survive
* Ink's stdout capture in the REPL / bridge UI.
*/
import { appendFileSync, mkdirSync, existsSync } from 'node:fs'
import { homedir } from 'node:os'
import { join } from 'node:path'
const LOG_PATH = join(homedir(), '.claude', 'rc-debug.log')
function ensureLogDir() {
const dir = join(homedir(), '.claude')
if (!existsSync(dir)) mkdirSync(dir, { recursive: true })
}
let headerWritten = false
export function rcLog(msg: string): void {
try {
if (!headerWritten) {
ensureLogDir()
appendFileSync(
LOG_PATH,
`\n===== RC-DEBUG session ${new Date().toISOString()} =====\n`,
)
headerWritten = true
}
const ts = new Date().toISOString().slice(11, 23) // HH:mm:ss.SSS
appendFileSync(LOG_PATH, `[${ts}] ${msg}\n`)
} catch {
// best-effort — never crash the bridge
}
}
/** Clear the log file at session start. */
export function rcLogClear(): void {
try {
ensureLogDir()
appendFileSync(LOG_PATH, '')
} catch {}
}