( level: LogLevel, data: LogData, msg?: string, ...args: LogArgs )
| 83 | }) |
| 84 | |
| 85 | function 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 |
no test coverage detected