UNPKG

nativescript

Version:

Command-line interface for building NativeScript projects

66 lines 3.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DeviceLogProviderBase = void 0; const events_1 = require("events"); const helpers_1 = require("../helpers"); class DeviceLogProviderBase extends events_1.EventEmitter { constructor($logFilter, $logger, $logSourceMapService) { super(); this.$logFilter = $logFilter; this.$logger = $logger; this.$logSourceMapService = $logSourceMapService; this.devicesLogOptions = {}; } async setSourceFileLocation(pathToOriginalFile) { try { await this.$logSourceMapService.setSourceMapConsumerForFile(pathToOriginalFile); } catch (err) { this.$logger.trace("Error while trying to set source map file", err); } } setApplicationPidForDevice(deviceIdentifier, pid) { this.setDeviceLogOptionsProperty(deviceIdentifier, (deviceLogOptions) => deviceLogOptions.applicationPid, pid); } setApplicationIdForDevice(deviceIdentifier, appId) { this.setDeviceLogOptionsProperty(deviceIdentifier, (deviceLogOptions) => deviceLogOptions.applicationId, appId); } setProjectNameForDevice(deviceIdentifier, projectName) { this.setDeviceLogOptionsProperty(deviceIdentifier, (deviceLogOptions) => deviceLogOptions.projectName, projectName); } setProjectDirForDevice(deviceIdentifier, projectDir) { this.setDeviceLogOptionsProperty(deviceIdentifier, (deviceLogOptions) => deviceLogOptions.projectDir, projectDir); } setDefaultLogLevelForDevice(deviceIdentifier) { const logLevel = (this.devicesLogOptions[deviceIdentifier] && this.devicesLogOptions[deviceIdentifier].logLevel) || this.$logFilter.loggingLevel; this.setLogLevel(logLevel, deviceIdentifier); } getApplicationPidForDevice(deviceIdentifier) { return (this.devicesLogOptions[deviceIdentifier] && this.devicesLogOptions[deviceIdentifier].applicationPid); } getApplicationIdForDevice(deviceIdentifier) { return (this.devicesLogOptions[deviceIdentifier] && this.devicesLogOptions[deviceIdentifier].applicationId); } getDeviceLogOptionsForDevice(deviceIdentifier) { const loggingOptions = this.devicesLogOptions[deviceIdentifier]; if (!loggingOptions) { this.setDefaultLogLevelForDevice(deviceIdentifier); } return this.devicesLogOptions[deviceIdentifier]; } setDeviceLogOptionsProperty(deviceIdentifier, propNameFunction, propertyValue) { const propertyName = (0, helpers_1.getPropertyName)(propNameFunction); if (propertyName) { this.devicesLogOptions[deviceIdentifier] = this.devicesLogOptions[deviceIdentifier] || {}; this.devicesLogOptions[deviceIdentifier][propertyName] = propertyValue; } } } exports.DeviceLogProviderBase = DeviceLogProviderBase; //# sourceMappingURL=device-log-provider-base.js.map