11import { getRemoteXPCServices } from './remotexpc-utils' ;
2- import { log } from '../logger' ;
32import type {
43 CrashReportsService as RemoteXPCCrashReportsService ,
54 RemoteXpcConnection ,
65} from 'appium-ios-remotexpc' ;
76import type { Pyidevice as PyideviceClient } from './clients/py-ios-device-client' ;
87import { Pyidevice } from './clients/py-ios-device-client' ;
8+ import type { AppiumLogger } from '@appium/types' ;
99
1010const CRASH_REPORT_EXTENSIONS = [ '.ips' ] ;
1111const MAX_FILES_IN_ERROR = 10 ;
@@ -20,13 +20,16 @@ const MAX_FILES_IN_ERROR = 10;
2020export 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 ) {
0 commit comments