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

Function readRecentAndroidLogcatForPackage

src/daemon/app-log-android.ts:49–71  ·  view source on GitHub ↗
(
  deviceId: string,
  appBundleId: string,
)

Source from the content-addressed store, hash-verified

47}
48
49export async function readRecentAndroidLogcatForPackage(
50 deviceId: string,
51 appBundleId: string,
52): Promise<{ pid: string | null; text: string; recoveredPids: string[] } | null> {
53 assertAndroidPackageArgSafe(appBundleId);
54 const pid = await resolveAndroidPid(deviceId, appBundleId);
55 const adb = resolveAndroidAdbExecutor(androidDeviceForSerial(deviceId));
56 const text = await captureAndroidLogcatWithAdb(adb, { lines: 4000, timeoutMs: 3_000 }).catch(
57 () => '',
58 );
59 if (text.trim().length === 0) {
60 return null;
61 }
62 const recoveredPids = collectAndroidPackagePids(text, appBundleId, pid);
63 if (recoveredPids.length === 0) {
64 return null;
65 }
66 const filteredText = filterAndroidLogcatToPids(text, appBundleId, recoveredPids);
67 if (filteredText.trim().length === 0) {
68 return null;
69 }
70 return { pid, text: filteredText, recoveredPids };
71}
72
73export async function startAndroidAppLog(
74 deviceId: string,

Callers 2

Calls 7

androidDeviceForSerialFunction · 0.90
resolveAndroidPidFunction · 0.85

Tested by

no test coverage detected