@@ -131,7 +131,8 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
131
131
deviceLogChildProcess = this . getDeviceLogProcess ( deviceId ) ;
132
132
if ( deviceLogChildProcess . stdout ) {
133
133
deviceLogChildProcess . stdout . on ( "data" , ( data : NodeBuffer ) => {
134
- let dataAsString = data . toString ( ) ;
134
+ const dataAsString = data . toString ( ) ;
135
+
135
136
if ( pid ) {
136
137
if ( dataAsString . indexOf ( `[${ pid } ]` ) > - 1 || dataAsString . indexOf ( ` ${ pid } ` ) > - 1 ) {
137
138
process . stdout . write ( dataAsString ) ;
@@ -144,32 +145,32 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
144
145
145
146
if ( deviceLogChildProcess . stderr ) {
146
147
deviceLogChildProcess . stderr . on ( "data" , ( data : string ) => {
147
- let dataAsString = data . toString ( ) ;
148
+ const dataAsString = data . toString ( ) ;
149
+
148
150
if ( pid ) {
149
151
if ( dataAsString . indexOf ( `[${ pid } ]` ) > - 1 || dataAsString . indexOf ( ` ${ pid } ` ) > - 1 ) {
150
152
process . stdout . write ( dataAsString ) ;
151
153
}
152
154
} else {
153
155
process . stdout . write ( dataAsString ) ;
154
156
}
155
- process . stdout . write ( data . toString ( ) ) ;
156
157
} ) ;
157
158
}
158
159
}
159
160
160
161
return deviceLogChildProcess ;
161
162
}
162
163
163
- public getDeviceLogProcess ( deviceId : string ) : any {
164
- const device = this . getDeviceFromIdentifier ( deviceId ) || { } ;
165
- const deviceVersion = this . getDeviceFromIdentifier ( deviceId ) . runtimeVersion || "" ;
166
- const majorVersion = deviceVersion . split ( "." ) [ 0 ] ;
167
-
164
+ public getDeviceLogProcess ( deviceId : string , predicate ?: string ) : any {
168
165
if ( ! this . isDeviceLogOperationStarted ) {
169
- if ( majorVersion && parseInt ( majorVersion ) >= 11 ) {
170
- this . deviceLogChildProcess = this . simctl . getLog ( deviceId ) ;
166
+ const device = this . getDeviceFromIdentifier ( deviceId ) ;
167
+ const deviceVersion = device ? device . runtimeVersion : "" ;
168
+ const majorVersion = deviceVersion . split ( "." ) [ 0 ] ;
169
+
170
+ if ( majorVersion && parseInt ( majorVersion ) >= 11 ) {
171
+ this . deviceLogChildProcess = this . simctl . getLog ( deviceId , predicate ) ;
171
172
} else {
172
- let logFilePath = path . join ( osenv . home ( ) , "Library" , "Logs" , "CoreSimulator" , deviceId , "system.log" ) ;
173
+ const logFilePath = path . join ( osenv . home ( ) , "Library" , "Logs" , "CoreSimulator" , deviceId , "system.log" ) ;
173
174
this . deviceLogChildProcess = require ( "child_process" ) . spawn ( "tail" , [ '-f' , '-n' , '1' , logFilePath ] ) ;
174
175
}
175
176
0 commit comments