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

Commit

Permalink
Don't duplicate the messages from logcat
Browse files Browse the repository at this point in the history
  • Loading branch information
Fatme Havaluova authored and Fatme Havaluova committed Nov 24, 2015
1 parent 2811f51 commit 1a38a63
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mobile/android/logcat-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
import byline = require("byline");

export class LogcatHelper implements Mobile.ILogcatHelper {
private mapDeviceToLoggingStarted: IDictionary<boolean>;

constructor(private $childProcess: IChildProcess,
private $deviceLogProvider: Mobile.IDeviceLogProvider,
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
private $logger: ILogger,
private $staticConfig: Config.IStaticConfig) { }
private $staticConfig: Config.IStaticConfig) {
this.mapDeviceToLoggingStarted = Object.create(null);
}

public start(deviceIdentifier: string): void {
if(deviceIdentifier) {
if (deviceIdentifier && !this.mapDeviceToLoggingStarted[deviceIdentifier]) {
let adbPath = this.$staticConfig.getAdbFilePath().wait();
// remove cached logs:
this.$childProcess.spawnFromEvent(adbPath, ["-s", deviceIdentifier, "logcat", "-c"], "close", {}, {throwError: false}).wait();
Expand All @@ -31,6 +35,8 @@ export class LogcatHelper implements Mobile.ILogcatHelper {
let lineText = line.toString();
this.$deviceLogProvider.logData(lineText, this.$devicePlatformsConstants.Android, deviceIdentifier);
});

this.mapDeviceToLoggingStarted[deviceIdentifier] = true;
}
}
}
Expand Down

0 comments on commit 1a38a63

Please sign in to comment.