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