nativescript
Version:
Command-line interface for building NativeScript projects
53 lines • 2.11 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LogFilter = void 0;
const yok_1 = require("../yok");
class LogFilter {
constructor($devicePlatformsConstants, $injector, $loggingLevels) {
this.$devicePlatformsConstants = $devicePlatformsConstants;
this.$injector = $injector;
this.$loggingLevels = $loggingLevels;
this._loggingLevel = this.$loggingLevels.info;
}
get loggingLevel() {
return this._loggingLevel;
}
set loggingLevel(logLevel) {
if (this.verifyLogLevel(logLevel)) {
this._loggingLevel = logLevel;
}
}
filterData(platform, data, loggingOptions = {}) {
loggingOptions = loggingOptions || {};
const deviceLogFilter = this.getDeviceLogFilterInstance(platform);
loggingOptions.logLevel = loggingOptions.logLevel || this.loggingLevel;
if (deviceLogFilter) {
return deviceLogFilter.filterData(data, loggingOptions);
}
// In case the platform is not valid, just return the data without filtering.
return data;
}
getDeviceLogFilterInstance(platform) {
if (platform) {
if (platform.toLowerCase() ===
this.$devicePlatformsConstants.iOS.toLowerCase() ||
platform.toLowerCase() ===
this.$devicePlatformsConstants.visionOS.toLowerCase()) {
return this.$injector.resolve("iOSLogFilter");
}
else if (platform.toLowerCase() ===
this.$devicePlatformsConstants.Android.toLowerCase()) {
return this.$injector.resolve("androidLogFilter");
}
}
return null;
}
verifyLogLevel(logLevel) {
const upperCaseLogLevel = (logLevel || "").toUpperCase();
return (upperCaseLogLevel === this.$loggingLevels.info.toUpperCase() ||
upperCaseLogLevel === this.$loggingLevels.full.toUpperCase());
}
}
exports.LogFilter = LogFilter;
yok_1.injector.register("logFilter", LogFilter);
//# sourceMappingURL=log-filter.js.map