MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / splitAndLog

Function splitAndLog

web/src/util/logger.ts:85–111  ·  view source on GitHub ↗
(
  level: LogLevel,
  data: LogData,
  msg?: string,
  ...args: LogArgs
)

Source from the content-addressed store, hash-verified

83})
84
85function splitAndLog(
86 level: LogLevel,
87 data: LogData,
88 msg?: string,
89 ...args: LogArgs
90): void {
91 const formattedMsg = format(msg ?? '', ...args)
92 const availableDataLimit = MAX_LENGTH - BUFFER - formattedMsg.length
93
94 // split data recursively into chunks small enough to log
95 const processedData: unknown[] = splitData({
96 data,
97 maxChunkSize: availableDataLimit,
98 })
99
100 if (processedData.length === 1) {
101 pinoLogger[level](processedData[0], msg, ...args)
102 return
103 }
104
105 processedData.forEach((chunk, index) => {
106 pinoLogger[level](
107 chunk,
108 `${formattedMsg} (chunk ${index + 1}/${processedData.length})`,
109 )
110 })
111}
112
113// In dev mode, use appendFileSync for real-time file logging (Bun has issues with pino sync)
114// Also output to console so logs remain visible in the terminal

Callers 1

logWithSyncFunction · 0.85

Calls 1

splitDataFunction · 0.90

Tested by

no test coverage detected