|
1 | 1 | import { DEBUGGER_PORT_FOUND_EVENT_NAME, DEVICE_LOG_EVENT_NAME } from "../common/constants"; |
2 | | -import { cache } from "../common/decorators"; |
3 | 2 | import { EventEmitter } from "events"; |
4 | 3 |
|
5 | 4 | export class IOSLogParserService extends EventEmitter implements IIOSLogParserService { |
6 | 5 | private static MESSAGE_REGEX = /NativeScript debugger has opened inspector socket on port (\d+?) for (.*)[.]/; |
7 | 6 |
|
| 7 | + private startedDeviceLogInstances: IDictionary<boolean> = {}; |
| 8 | + |
8 | 9 | constructor(private $deviceLogProvider: Mobile.IDeviceLogProvider, |
9 | 10 | private $iosDeviceOperations: IIOSDeviceOperations, |
10 | 11 | private $iOSSimulatorLogProvider: Mobile.IiOSSimulatorLogProvider, |
11 | 12 | private $logger: ILogger, |
12 | 13 | private $projectData: IProjectData) { |
13 | | - super(); |
14 | | - } |
| 14 | + super(); |
| 15 | + } |
15 | 16 |
|
16 | 17 | public startParsingLog(device: Mobile.IDevice): void { |
17 | 18 | this.$deviceLogProvider.setProjectNameForDevice(device.deviceInfo.identifier, this.$projectData.projectName); |
18 | 19 |
|
19 | | - this.startParsingLogCore(device); |
20 | | - this.startLogProcess(device); |
| 20 | + if (!this.startedDeviceLogInstances[device.deviceInfo.identifier]) { |
| 21 | + this.startParsingLogCore(device); |
| 22 | + this.startLogProcess(device); |
| 23 | + this.startedDeviceLogInstances[device.deviceInfo.identifier] = true; |
| 24 | + } |
21 | 25 | } |
22 | 26 |
|
23 | | - @cache() |
24 | 27 | private startParsingLogCore(device: Mobile.IDevice): void { |
25 | 28 | const logProvider = device.isEmulator ? this.$iOSSimulatorLogProvider : this.$iosDeviceOperations; |
26 | 29 | logProvider.on(DEVICE_LOG_EVENT_NAME, (response: IOSDeviceLib.IDeviceLogData) => this.processDeviceLogResponse(response)); |
|
0 commit comments