-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathdevice-log-stream.ts
31 lines (24 loc) · 1.22 KB
/
device-log-stream.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
export class OpenDeviceLogStreamCommand implements ICommand {
private static NOT_SPECIFIED_DEVICE_ERROR_MESSAGE = "More than one device found. Specify device explicitly.";
constructor(private $devicesService: Mobile.IDevicesService,
private $errors: IErrors,
private $commandsService: ICommandsService,
private $options: IOptions,
private $deviceLogProvider: Mobile.IDeviceLogProvider,
private $loggingLevels: Mobile.ILoggingLevels,
$iOSSimulatorLogProvider: Mobile.IiOSSimulatorLogProvider) {
$iOSSimulatorLogProvider.setShouldDispose(false);
}
allowedParameters: ICommandParameter[] = [];
public async execute(args: string[]): Promise<void> {
this.$deviceLogProvider.setLogLevel(this.$loggingLevels.full);
await this.$devicesService.initialize({ deviceId: this.$options.device, skipInferPlatform: true });
if (this.$devicesService.deviceCount > 1) {
await this.$commandsService.tryExecuteCommand("device", []);
this.$errors.fail(OpenDeviceLogStreamCommand.NOT_SPECIFIED_DEVICE_ERROR_MESSAGE);
}
const action = (device: Mobile.IiOSDevice) => device.openDeviceLogStream();
await this.$devicesService.execute(action);
}
}
$injector.registerCommand(["device|log", "devices|log"], OpenDeviceLogStreamCommand);