MCPcopy
hub / github.com/claude-code-best/claude-code / getLogWriter

Function getLogWriter

src/utils/errorLogSink.ts:86–110  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

84}
85
86function getLogWriter(path: string): JsonlWriter {
87 let writer = logWriters.get(path)
88 if (!writer) {
89 const dir = dirname(path)
90 writer = createJsonlWriter({
91 // sync IO: called from sync context
92 writeFn: (content: string) => {
93 try {
94 // Happy-path: directory already exists
95 getFsImplementation().appendFileSync(path, content)
96 } catch {
97 // If any error occurs, assume it was due to missing directory
98 getFsImplementation().mkdirSync(dir)
99 // Retry appending
100 getFsImplementation().appendFileSync(path, content)
101 }
102 },
103 flushIntervalMs: 1000,
104 maxBufferSize: 50,
105 })
106 logWriters.set(path, writer)
107 registerCleanup(async () => writer?.dispose())
108 }
109 return writer
110}
111
112function appendToLog(path: string, message: object): void {
113 if (process.env.USER_TYPE !== 'ant') {

Callers 3

appendToLogFunction · 0.85
logMCPErrorImplFunction · 0.85
logMCPDebugImplFunction · 0.85

Calls 6

createJsonlWriterFunction · 0.85
getFsImplementationFunction · 0.85
registerCleanupFunction · 0.85
setMethod · 0.80
disposeMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected