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