Add logs support for physical devices

Summary:
There's a bit of an oddity with `idb` that the `stream` parameter is implied even though the docs say otherwise and if you try to use it, it'll give you a strange Python error. That's likely why we never implemented it.

Now, it works just as it does using local tooling.

Reviewed By: mweststrate

Differential Revision: D26228036

fbshipit-source-id: e20cb31167170ba0501e2929ed129305cb9aaf2c
This commit is contained in:
Pascal Hartig
2021-02-05 03:51:26 -08:00
committed by Facebook GitHub Bot
parent 05acdc99b0
commit e788bb09be

View File

@@ -79,9 +79,6 @@ export default class IOSDevice extends BaseDevice {
}
startLogListener(retries: number = 3) {
if (this.deviceType === 'physical') {
return;
}
if (retries === 0) {
console.warn('Attaching iOS log listener continuously failed.');
return;
@@ -91,24 +88,36 @@ export default class IOSDevice extends BaseDevice {
? ['--set', process.env.DEVICE_SET_PATH]
: [];
this.log = child_process.spawn(
'xcrun',
[
'simctl',
...deviceSetPath,
'spawn',
this.serial,
'log',
'stream',
'--style',
'json',
'--predicate',
'senderImagePath contains "Containers"',
'--info',
'--debug',
],
{},
);
const extraArgs = [
'--style',
'json',
'--predicate',
'senderImagePath contains "Containers"',
'--debug',
'--info',
];
if (this.deviceType === 'physical') {
this.log = child_process.spawn(
'idb',
['log', '--udid', this.serial, '--', ...extraArgs],
{},
);
} else {
this.log = child_process.spawn(
'xcrun',
[
'simctl',
...deviceSetPath,
'spawn',
this.serial,
'log',
'stream',
...extraArgs,
],
{},
);
}
this.log.on('error', (err: Error) => {
console.error('iOS log tailer error', err);