Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit 1a38a63

Browse files
Fatme HavaluovaFatme Havaluova
Fatme Havaluova
authored and
Fatme Havaluova
committed
Don't duplicate the messages from logcat
Fixes NativeScript/nativescript-cli#1130
1 parent 2811f51 commit 1a38a63

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

mobile/android/logcat-helper.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
import byline = require("byline");
44

55
export class LogcatHelper implements Mobile.ILogcatHelper {
6+
private mapDeviceToLoggingStarted: IDictionary<boolean>;
7+
68
constructor(private $childProcess: IChildProcess,
79
private $deviceLogProvider: Mobile.IDeviceLogProvider,
810
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
911
private $logger: ILogger,
10-
private $staticConfig: Config.IStaticConfig) { }
12+
private $staticConfig: Config.IStaticConfig) {
13+
this.mapDeviceToLoggingStarted = Object.create(null);
14+
}
1115

1216
public start(deviceIdentifier: string): void {
13-
if(deviceIdentifier) {
17+
if (deviceIdentifier && !this.mapDeviceToLoggingStarted[deviceIdentifier]) {
1418
let adbPath = this.$staticConfig.getAdbFilePath().wait();
1519
// remove cached logs:
1620
this.$childProcess.spawnFromEvent(adbPath, ["-s", deviceIdentifier, "logcat", "-c"], "close", {}, {throwError: false}).wait();
@@ -31,6 +35,8 @@ export class LogcatHelper implements Mobile.ILogcatHelper {
3135
let lineText = line.toString();
3236
this.$deviceLogProvider.logData(lineText, this.$devicePlatformsConstants.Android, deviceIdentifier);
3337
});
38+
39+
this.mapDeviceToLoggingStarted[deviceIdentifier] = true;
3440
}
3541
}
3642
}

0 commit comments

Comments
 (0)