Skip to content

Commit 00f04a7

Browse files
committed
fix: logger
1 parent dac9307 commit 00f04a7

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

lib/device/crash-reports-client.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {getRemoteXPCServices} from './remotexpc-utils';
2-
import {log} from '../logger';
32
import type {
43
CrashReportsService as RemoteXPCCrashReportsService,
54
RemoteXpcConnection,
65
} from 'appium-ios-remotexpc';
76
import type {Pyidevice as PyideviceClient} from './clients/py-ios-device-client';
87
import {Pyidevice} from './clients/py-ios-device-client';
8+
import type {AppiumLogger} from '@appium/types';
99

1010
const CRASH_REPORT_EXTENSIONS = ['.ips'];
1111
const MAX_FILES_IN_ERROR = 10;
@@ -20,13 +20,16 @@ const MAX_FILES_IN_ERROR = 10;
2020
export class CrashReportsClient {
2121
private readonly service: RemoteXPCCrashReportsService | PyideviceClient;
2222
private readonly remoteXPCConnection?: RemoteXpcConnection;
23+
private readonly log: AppiumLogger;
2324

2425
private constructor(
2526
service: RemoteXPCCrashReportsService | PyideviceClient,
27+
log: AppiumLogger,
2628
remoteXPCConnection?: RemoteXpcConnection,
2729
) {
2830
this.service = service;
2931
this.remoteXPCConnection = remoteXPCConnection;
32+
this.log = log;
3033
}
3134

3235
//#region Public Static Methods
@@ -38,7 +41,11 @@ export class CrashReportsClient {
3841
* @param useRemoteXPC - Whether to use remotexpc
3942
* @returns CrashReportsClient instance
4043
*/
41-
static async create(udid: string, useRemoteXPC: boolean): Promise<CrashReportsClient> {
44+
static async create(
45+
udid: string,
46+
useRemoteXPC: boolean,
47+
log: AppiumLogger,
48+
): Promise<CrashReportsClient> {
4249
if (useRemoteXPC) {
4350
const client = await CrashReportsClient.withRemoteXpcConnection(async () => {
4451
const Services = await getRemoteXPCServices();
@@ -47,15 +54,15 @@ export class CrashReportsClient {
4754
service: crashReportsService,
4855
connection: remoteXPC,
4956
};
50-
});
57+
}, log);
5158
if (client) {
5259
return client;
5360
}
5461
}
5562

5663
// Fallback to Pyidevice
5764
const pyideviceClient = new Pyidevice({udid, log});
58-
return new CrashReportsClient(pyideviceClient);
65+
return new CrashReportsClient(pyideviceClient, log);
5966
}
6067

6168
//#endregion
@@ -141,7 +148,9 @@ export class CrashReportsClient {
141148
try {
142149
await this.remoteXPCConnection.close();
143150
} catch (err) {
144-
log.warn(`Error closing RemoteXPC connection for crash reports: ${(err as Error).message}`);
151+
this.log.warn(
152+
`Error closing RemoteXPC connection for crash reports: ${(err as Error).message}`,
153+
);
145154
}
146155
}
147156
}
@@ -167,13 +176,14 @@ export class CrashReportsClient {
167176
service: RemoteXPCCrashReportsService;
168177
connection: RemoteXpcConnection;
169178
}>,
179+
log: AppiumLogger,
170180
): Promise<CrashReportsClient | null> {
171181
let remoteXPCConnection: RemoteXpcConnection | undefined;
172182
let succeeded = false;
173183
try {
174184
const {service, connection} = await operation();
175185
remoteXPCConnection = connection;
176-
const client = new CrashReportsClient(service, remoteXPCConnection);
186+
const client = new CrashReportsClient(service, log, remoteXPCConnection);
177187
succeeded = true;
178188
return client;
179189
} catch (err: any) {

lib/device/log/ios-crash-log.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export class IOSCrashLog extends IOSLog<TSerializedEntry, TSerializedEntry> {
124124
this._realDeviceClient = await CrashReportsClient.create(
125125
this._udid as string,
126126
this._useRemoteXPC,
127+
this.log,
127128
);
128129
} catch (err) {
129130
this.log.error(

0 commit comments

Comments
 (0)