Skip to content

Commit 75e6a79

Browse files
committed
refactor(ios): drop the startDeviceLogStream availability check
ios-device-lib is pinned to 0.10.0, which always has it. Also give IiOSLogEntry and IiOSLogStreamOptions their own doc comments and describe what pid is used for.
1 parent b001fe5 commit 75e6a79

3 files changed

Lines changed: 15 additions & 31 deletions

File tree

‎lib/common/definitions/mobile.d.ts‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,12 @@ declare global {
151151
): Mobile.IAndroidDeviceHashService;
152152
}
153153

154-
/**
155-
* Describes log stream options
156-
*/
157154
/**
158155
* A structured unified logging (os_log) entry.
159156
*/
160157
interface IiOSLogEntry {
161158
/**
162-
* Together with the thread, tells apart messages logged at the same time.
159+
* Scopes the ids of split messages, which are only unique per process.
163160
*/
164161
pid?: number;
165162
thread?: number;
@@ -175,6 +172,9 @@ declare global {
175172
message: string;
176173
}
177174

175+
/**
176+
* Describes log stream options
177+
*/
178178
interface IiOSLogStreamOptions {
179179
/**
180180
* This is the --predicate option which will be passed to `log stream` command
@@ -1369,12 +1369,8 @@ declare global {
13691369

13701370
/**
13711371
* Streams structured logs of the process with the given executable name.
1372-
* Returns false when the installed ios-device-lib cannot stream them.
13731372
*/
1374-
startDeviceLogStream(
1375-
deviceIdentifier: string,
1376-
processName: string,
1377-
): boolean;
1373+
startDeviceLogStream(deviceIdentifier: string, processName: string): void;
13781374

13791375
apps(
13801376
deviceIdentifiers: string[],

‎lib/common/mobile/ios/device/ios-device-operations.ts‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,8 @@ export class IOSDeviceOperations
139139
public startDeviceLogStream(
140140
deviceIdentifier: string,
141141
processName: string,
142-
): boolean {
142+
): void {
143143
this.assertIsInitialized();
144-
if (typeof this.deviceLib.startDeviceLogStream !== "function") {
145-
return false;
146-
}
147-
148144
this.setShouldDispose(false);
149145
this.$logger.trace(
150146
`Streaming structured logs of ${processName} on device with identifier: ${deviceIdentifier}.`,
@@ -155,7 +151,6 @@ export class IOSDeviceOperations
155151
this.deviceLib.startDeviceLogStream([
156152
{ deviceId: deviceIdentifier, processName },
157153
]);
158-
return true;
159154
}
160155

161156
public async apps(

‎lib/common/mobile/ios/device/ios-device.ts‎

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -99,30 +99,23 @@ export class IOSDevice extends IOSDeviceBase {
9999
const processName = this.$deviceLogProvider.getProjectNameForDevice(
100100
this.deviceInfo.identifier,
101101
);
102-
if (processName && this.startStructuredDeviceLog(processName)) {
103-
return;
102+
if (processName) {
103+
this.startStructuredDeviceLog(processName);
104+
} else {
105+
this.startSyslogDeviceLog();
104106
}
105-
106-
this.startSyslogDeviceLog();
107107
}
108108

109-
private startStructuredDeviceLog(processName: string): boolean {
109+
private startStructuredDeviceLog(processName: string): void {
110110
this._deviceLogEntryHandler = this.actionOnDeviceLogEntry.bind(this);
111111
this.$iosDeviceOperations.on(
112112
commonConstants.DEVICE_LOG_ENTRY_EVENT_NAME,
113113
this._deviceLogEntryHandler,
114114
);
115-
if (
116-
this.$iosDeviceOperations.startDeviceLogStream(
117-
this.deviceInfo.identifier,
118-
processName,
119-
)
120-
) {
121-
return true;
122-
}
123-
124-
this.removeDeviceLogEntryHandler();
125-
return false;
115+
this.$iosDeviceOperations.startDeviceLogStream(
116+
this.deviceInfo.identifier,
117+
processName,
118+
);
126119
}
127120

128121
private startSyslogDeviceLog(): void {

0 commit comments

Comments
 (0)