3
3
import byline = require( "byline" ) ;
4
4
5
5
export class LogcatHelper implements Mobile . ILogcatHelper {
6
+ private mapDeviceToLoggingStarted : IDictionary < boolean > ;
7
+
6
8
constructor ( private $childProcess : IChildProcess ,
7
9
private $deviceLogProvider : Mobile . IDeviceLogProvider ,
8
10
private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
9
11
private $logger : ILogger ,
10
- private $staticConfig : Config . IStaticConfig ) { }
12
+ private $staticConfig : Config . IStaticConfig ) {
13
+ this . mapDeviceToLoggingStarted = Object . create ( null ) ;
14
+ }
11
15
12
16
public start ( deviceIdentifier : string ) : void {
13
- if ( deviceIdentifier ) {
17
+ if ( deviceIdentifier && ! this . mapDeviceToLoggingStarted [ deviceIdentifier ] ) {
14
18
let adbPath = this . $staticConfig . getAdbFilePath ( ) . wait ( ) ;
15
19
// remove cached logs:
16
20
this . $childProcess . spawnFromEvent ( adbPath , [ "-s" , deviceIdentifier , "logcat" , "-c" ] , "close" , { } , { throwError : false } ) . wait ( ) ;
@@ -22,6 +26,7 @@ export class LogcatHelper implements Mobile.ILogcatHelper {
22
26
} ) ;
23
27
24
28
adbLogcat . on ( "close" , ( code : number ) => {
29
+ this . mapDeviceToLoggingStarted [ deviceIdentifier ] = false ;
25
30
if ( code !== 0 ) {
26
31
this . $logger . trace ( "ADB process exited with code " + code . toString ( ) ) ;
27
32
}
@@ -31,6 +36,8 @@ export class LogcatHelper implements Mobile.ILogcatHelper {
31
36
let lineText = line . toString ( ) ;
32
37
this . $deviceLogProvider . logData ( lineText , this . $devicePlatformsConstants . Android , deviceIdentifier ) ;
33
38
} ) ;
39
+
40
+ this . mapDeviceToLoggingStarted [ deviceIdentifier ] = true ;
34
41
}
35
42
}
36
43
}
0 commit comments