MCPcopy Index your code
hub / github.com/getsentry/XcodeBuildMCP / setLogFile

Function setLogFile

src/utils/logger.ts:166–212  ·  view source on GitHub ↗
(path: string | null)

Source from the content-addressed store, hash-verified

164}
165
166export function setLogFile(path: string | null): void {
167 if (!path) {
168 if (logFileStream) {
169 try {
170 logFileStream.end();
171 } catch {
172 // ignore
173 }
174 }
175 logFileStream = null;
176 logFilePath = null;
177 return;
178 }
179
180 if (logFilePath === path && logFileStream) {
181 return;
182 }
183
184 if (logFileStream) {
185 try {
186 logFileStream.end();
187 } catch {
188 // ignore
189 }
190 }
191
192 try {
193 const stream = createWriteStream(path, { flags: 'a' });
194 stream.on('error', (error) => {
195 if (stream !== logFileStream) return;
196 logFileStream = null;
197 logFilePath = null;
198 const message = error instanceof Error ? error.message : String(error);
199 const timestamp = new Date().toISOString();
200 if (!areProcessStdioWritesSuppressed()) {
201 console.error(`[${timestamp}] [ERROR] Log file disabled after error: ${message}`);
202 }
203 });
204 logFileStream = stream;
205 logFilePath = path;
206 const timestamp = new Date().toISOString();
207 logFileStream.write(`[${timestamp}] [INFO] Log file initialized\n`);
208 } catch {
209 logFileStream = null;
210 logFilePath = null;
211 }
212}
213
214/**
215 * Get the current client-requested log level

Callers 1

mainFunction · 0.90

Calls 3

createWriteStreamFunction · 0.85
writeMethod · 0.65

Tested by

no test coverage detected