| 118 | } |
| 119 | |
| 120 | emit(entry: LogEntry): void { |
| 121 | const config = this.config; |
| 122 | if (config === undefined || config.level === 'off') return; |
| 123 | if (!levelEnabled(config.level, entry.level)) return; |
| 124 | |
| 125 | const session = this.resolveSessionEntry(entry); |
| 126 | if (session !== undefined) { |
| 127 | const omitContextKeys = llmRequestSessionLogOmittedKeys(entry); |
| 128 | const sessionFormatted = formatEntry(entry, { |
| 129 | omitContextKeys, |
| 130 | }); |
| 131 | if (!sessionFormatted.dropped) { |
| 132 | session.sink.enqueue(sessionFormatted.text + '\n'); |
| 133 | } |
| 134 | } else { |
| 135 | const formatted = formatEntry(entry); |
| 136 | if (formatted.dropped) return; |
| 137 | this.globalSink?.enqueue(formatted.text + '\n'); |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | detachSession(logId: string): Promise<void> { |
| 142 | const entry = this.sessions.get(logId); |