(newSink: ErrorLogSink)
| 109 | * the default command) without coordination. |
| 110 | */ |
| 111 | export function attachErrorLogSink(newSink: ErrorLogSink): void { |
| 112 | if (errorLogSink !== null) { |
| 113 | return |
| 114 | } |
| 115 | errorLogSink = newSink |
| 116 | |
| 117 | // Drain the queue immediately - errors should not be delayed |
| 118 | if (errorQueue.length > 0) { |
| 119 | const queuedEvents = [...errorQueue] |
| 120 | errorQueue.length = 0 |
| 121 | |
| 122 | for (const event of queuedEvents) { |
| 123 | switch (event.type) { |
| 124 | case 'error': |
| 125 | errorLogSink.logError(event.error) |
| 126 | break |
| 127 | case 'mcpError': |
| 128 | errorLogSink.logMCPError(event.serverName, event.error) |
| 129 | break |
| 130 | case 'mcpDebug': |
| 131 | errorLogSink.logMCPDebug(event.serverName, event.message) |
| 132 | break |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Logs an error to multiple destinations for debugging and monitoring. |
no outgoing calls
no test coverage detected