@@ -9,6 +9,8 @@ import * as os from "os";
9
9
import xcode = require( "./xcode" ) ;
10
10
let bplistParser = require ( "bplist-parser" ) ;
11
11
let osenv = require ( "osenv" ) ;
12
+ let isDeviceLogOperationStarted = false ;
13
+ let pid : string ;
12
14
13
15
export function getInstalledApplications ( deviceId : string ) : IFuture < IApplication [ ] > {
14
16
return ( ( ) => {
@@ -38,37 +40,41 @@ export function getInstalledApplications(deviceId: string): IFuture<IApplication
38
40
}
39
41
40
42
export function printDeviceLog ( deviceId : string , launchResult ?: string ) : void {
41
- let logFilePath = path . join ( osenv . home ( ) , "Library" , "Logs" , "CoreSimulator" , deviceId , "system.log" ) ;
42
- let pid : string ;
43
43
if ( launchResult ) {
44
44
pid = launchResult . split ( ":" ) [ 1 ] . trim ( ) ;
45
45
}
46
- let childProcess = require ( "child_process" ) . spawn ( "tail" , [ '-f' , '-n' , '1' , logFilePath ] ) ;
47
- if ( childProcess . stdout ) {
48
- childProcess . stdout . on ( "data" , ( data : NodeBuffer ) => {
49
- let dataAsString = data . toString ( ) ;
50
- if ( pid ) {
51
- if ( dataAsString . indexOf ( `[${ pid } ]` ) > - 1 ) {
46
+
47
+ if ( ! isDeviceLogOperationStarted ) {
48
+ let logFilePath = path . join ( osenv . home ( ) , "Library" , "Logs" , "CoreSimulator" , deviceId , "system.log" ) ;
49
+ let childProcess = require ( "child_process" ) . spawn ( "tail" , [ '-f' , '-n' , '1' , logFilePath ] ) ;
50
+ if ( childProcess . stdout ) {
51
+ childProcess . stdout . on ( "data" , ( data : NodeBuffer ) => {
52
+ let dataAsString = data . toString ( ) ;
53
+ if ( pid ) {
54
+ if ( dataAsString . indexOf ( `[${ pid } ]` ) > - 1 ) {
55
+ process . stdout . write ( dataAsString ) ;
56
+ }
57
+ } else {
52
58
process . stdout . write ( dataAsString ) ;
53
59
}
54
- } else {
55
- process . stdout . write ( dataAsString ) ;
56
- }
57
- } ) ;
58
- }
60
+ } ) ;
61
+ }
59
62
60
- if ( childProcess . stderr ) {
61
- childProcess . stderr . on ( "data" , ( data : string ) => {
62
- let dataAsString = data . toString ( ) ;
63
- if ( pid ) {
64
- if ( dataAsString . indexOf ( `[${ pid } ]` ) > - 1 ) {
63
+ if ( childProcess . stderr ) {
64
+ childProcess . stderr . on ( "data" , ( data : string ) => {
65
+ let dataAsString = data . toString ( ) ;
66
+ if ( pid ) {
67
+ if ( dataAsString . indexOf ( `[${ pid } ]` ) > - 1 ) {
68
+ process . stdout . write ( dataAsString ) ;
69
+ }
70
+ } else {
65
71
process . stdout . write ( dataAsString ) ;
66
72
}
67
- } else {
68
- process . stdout . write ( dataAsString ) ;
69
- }
70
- process . stdout . write ( data . toString ( ) ) ;
71
- } ) ;
73
+ process . stdout . write ( data . toString ( ) ) ;
74
+ } ) ;
75
+ }
76
+
77
+ isDeviceLogOperationStarted = true ;
72
78
}
73
79
}
74
80
0 commit comments