MCPcopy Index your code
hub / github.com/callstack/agent-device / startAppleAppLogStream

Function startAppleAppLogStream

src/daemon/app-log-ios.ts:302–350  ·  view source on GitHub ↗
(params: {
  backend: AppLogResult['backend'];
  cmd: string;
  args: string[];
  stream: fs.WriteStream;
  redactionPatterns: RegExp[];
  pidPath?: string;
  stopSignals?: NodeJS.Signals[];
})

Source from the content-addressed store, hash-verified

300}
301
302function startAppleAppLogStream(params: {
303 backend: AppLogResult['backend'];
304 cmd: string;
305 args: string[];
306 stream: fs.WriteStream;
307 redactionPatterns: RegExp[];
308 pidPath?: string;
309 stopSignals?: NodeJS.Signals[];
310}): AppLogResult {
311 let state: AppLogState = 'active';
312 const background = runCmdBackground(params.cmd, params.args, {
313 allowFailure: true,
314 captureOutput: false,
315 });
316 void background.wait.catch(() => {});
317 const child = background.child;
318 const writer = createLineWriter(params.stream, { redactionPatterns: params.redactionPatterns });
319 if (typeof child.pid === 'number') {
320 writePidFile(params.pidPath, child.pid);
321 }
322 const wait = attachChildToStream(child, params.stream, {
323 endStreamOnClose: true,
324 writer,
325 }).then(
326 (result) => {
327 state = result.exitCode === 0 ? 'ended' : 'failed';
328 clearPidFile(params.pidPath);
329 return result;
330 },
331 (error: unknown) => {
332 state = 'failed';
333 clearPidFile(params.pidPath);
334 throw error;
335 },
336 );
337 return {
338 backend: params.backend,
339 getState: () => state,
340 startedAt: Date.now(),
341 wait,
342 stop: async () => {
343 for (const signal of params.stopSignals ?? ['SIGINT', 'SIGKILL']) {
344 child.kill(signal);
345 await waitForChildExit(wait);
346 }
347 clearPidFile(params.pidPath);
348 },
349 };
350}

Callers 3

startIosSimulatorAppLogFunction · 0.85
startMacOsAppLogFunction · 0.85
startIosDeviceAppLogFunction · 0.85

Calls 7

runCmdBackgroundFunction · 0.90
createLineWriterFunction · 0.90
writePidFileFunction · 0.90
attachChildToStreamFunction · 0.90
clearPidFileFunction · 0.90
waitForChildExitFunction · 0.90
killMethod · 0.45

Tested by

no test coverage detected