UNPKG

appium-xcuitest-driver

Version:

Appium driver for iOS using XCUITest for backend

81 lines 2.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.IOSDeviceLog = void 0; const appium_ios_device_1 = require("appium-ios-device"); const line_consuming_log_1 = require("./line-consuming-log"); class IOSDeviceLog extends line_consuming_log_1.LineConsumingLog { udid; showLogs; remoteXPCFacade; // Legacy service (appium-ios-device) legacyService = null; // RemoteXPC syslog service syslogService = null; constructor(opts) { super({ log: opts.log }); this.udid = opts.udid; this.showLogs = !!opts.showLogs; this.remoteXPCFacade = opts.remoteXPCFacade ?? null; } get isCapturing() { return !!this.syslogService || !!this.legacyService; } async startCapture() { if (this.isCapturing) { return; } const facade = this.remoteXPCFacade; if (facade && (await facade.determineAvailability())) { const started = await facade.attemptService('syslog', async (Services) => { const { syslogService, serviceDescriptor } = await Services.startSyslogTextService(this.udid); this.syslogService = syslogService; syslogService.on('message', this.onLog.bind(this)); syslogService.on('error', (err) => { this.log.warn(`Syslog RemoteXPC error: ${err.message}`); }); await syslogService.start(serviceDescriptor, { pid: -1, textMode: true }); return true; }); if (started) { this.log.info('Starting RemoteXPC syslog capture'); return; } await this.stopRemoteXPCCapture(); } await this.startLegacyCapture(); } async stopCapture() { await this.stopRemoteXPCCapture(); await this.stopLegacyCapture(); } async startLegacyCapture() { this.legacyService = await appium_ios_device_1.services.startSyslogService(this.udid); this.legacyService.start(this.onLog.bind(this)); } async stopLegacyCapture() { if (!this.legacyService) { return; } this.legacyService.close(); this.legacyService = null; } async stopRemoteXPCCapture() { if (!this.syslogService) { return; } try { await this.syslogService.stop(); } catch { } this.syslogService = null; } onLog(logLine) { this.broadcast(logLine); if (this.showLogs) { this.log.info(`[IOS_SYSLOG_ROW] ${logLine}`); } } } exports.IOSDeviceLog = IOSDeviceLog; exports.default = IOSDeviceLog; //# sourceMappingURL=ios-device-log.js.map