MCPcopy
hub / github.com/codeaashu/claude-code / logForDiagnosticsNoPII

Function logForDiagnosticsNoPII

src/utils/diagLogs.ts:27–57  ·  view source on GitHub ↗
(
  level: DiagnosticLogLevel,
  event: string,
  data?: Record<string, unknown>,
)

Source from the content-addressed store, hash-verified

25 */
26// sync IO: called from sync context
27export function logForDiagnosticsNoPII(
28 level: DiagnosticLogLevel,
29 event: string,
30 data?: Record<string, unknown>,
31): void {
32 const logFile = getDiagnosticLogFile()
33 if (!logFile) {
34 return
35 }
36
37 const entry: DiagnosticLogEntry = {
38 timestamp: new Date().toISOString(),
39 level,
40 event,
41 data: data ?? {},
42 }
43
44 const fs = getFsImplementation()
45 const line = jsonStringify(entry) + '\n'
46 try {
47 fs.appendFileSync(logFile, line)
48 } catch {
49 // If append fails, try creating the directory first
50 try {
51 fs.mkdirSync(dirname(logFile))
52 fs.appendFileSync(logFile, line)
53 } catch {
54 // Silently fail if logging is not possible
55 }
56 }
57}
58
59function getDiagnosticLogFile(): string | undefined {
60 return process.env.CLAUDE_CODE_DIAGNOSTICS_FILE

Callers 15

context.tsFile · 0.85
runFunction · 0.85
setupFunction · 0.85
onErrorMethod · 0.85
constructorMethod · 0.85
handleErrorMethod · 0.85
startMethod · 0.85
sendMethod · 0.85
git.tsFile · 0.85
hydrateRemoteSessionFunction · 0.85

Calls 3

getDiagnosticLogFileFunction · 0.85
getFsImplementationFunction · 0.85
jsonStringifyFunction · 0.85

Tested by

no test coverage detected