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

Commit 8fc0ffb

Browse files
author
Fatme
authored
Merge pull request #1082 from telerik/fatme/logs-multiple-simulators
fix (ios-simulator): Show logs from all running iOS simulators
2 parents 1b88f0e + dc053be commit 8fc0ffb

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

mobile/ios/simulator/ios-simulator-log-provider.ts

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
11
import { ChildProcess } from "child_process";
22

33
export class IOSSimulatorLogProvider implements Mobile.IiOSSimulatorLogProvider {
4-
private isStarted: boolean;
4+
private simulatorsLoggingEnabled: IDictionary<boolean> = {};
55

66
constructor(private $iOSSimResolver: Mobile.IiOSSimResolver,
77
private $deviceLogProvider: Mobile.IDeviceLogProvider,
88
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
9+
private $logger: ILogger,
910
private $processService: IProcessService) { }
1011

1112
public startLogProcess(deviceIdentifier: string): void {
12-
if (!this.isStarted) {
13+
if (!this.simulatorsLoggingEnabled[deviceIdentifier]) {
1314
const deviceLogChildProcess: ChildProcess = this.$iOSSimResolver.iOSSim.getDeviceLogProcess(deviceIdentifier, 'senderImagePath contains "NativeScript"');
1415

1516
const action = (data: NodeBuffer | string) => {
1617
this.$deviceLogProvider.logData(data.toString(), this.$devicePlatformsConstants.iOS, deviceIdentifier);
1718
};
1819

20+
if (deviceLogChildProcess) {
21+
deviceLogChildProcess.once("close", () => {
22+
this.simulatorsLoggingEnabled[deviceIdentifier] = false;
23+
});
24+
25+
deviceLogChildProcess.once("error", (err) => {
26+
this.$logger.trace(`Error is thrown for device with identifier ${deviceIdentifier}. More info: ${err.message}.`);
27+
this.simulatorsLoggingEnabled[deviceIdentifier] = false;
28+
});
29+
}
30+
1931
if (deviceLogChildProcess.stdout) {
2032
deviceLogChildProcess.stdout.on("data", action);
2133
}
@@ -26,7 +38,7 @@ export class IOSSimulatorLogProvider implements Mobile.IiOSSimulatorLogProvider
2638

2739
this.$processService.attachToProcessExitSignals(this, deviceLogChildProcess.kill);
2840

29-
this.isStarted = true;
41+
this.simulatorsLoggingEnabled[deviceIdentifier] = true;
3042
}
3143
}
3244
}

0 commit comments

Comments
 (0)