UNPKG

nativescript

Version:

Command-line interface for building NativeScript projects

46 lines 2.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AndroidLogFilter = void 0; const yok_1 = require("../../yok"); const os_1 = require("os"); class AndroidLogFilter { constructor($loggingLevels) { this.$loggingLevels = $loggingLevels; } filterData(data, loggingOptions = {}) { const specifiedLogLevel = (loggingOptions.logLevel || "").toUpperCase(); if (specifiedLogLevel === this.$loggingLevels.info) { const log = this.getConsoleLogFromLine(data, loggingOptions.applicationPid); if (log) { if (log.tag) { return (`${log.tag === "JS" ? "" : `${log.tag}: `}${log.message}` + os_1.EOL); } else { return log.message + os_1.EOL; } } return null; } return data + os_1.EOL; } getConsoleLogFromLine(lineText, pid) { if (pid && lineText.indexOf(pid) === -1) { return null; } let consoleLogMessage; const match = lineText.match(AndroidLogFilter.API_LEVEL_23_LINE_REGEX) || lineText.match(AndroidLogFilter.LINE_REGEX); if (match) { consoleLogMessage = { tag: match[1].trim(), message: match[2] }; } return consoleLogMessage; } } exports.AndroidLogFilter = AndroidLogFilter; //sample line is "I/Web Console( 4438): Received Event: deviceready at file:///storage/emulated/0/Icenium/com.telerik.TestApp/js/index.js:48" AndroidLogFilter.LINE_REGEX = /.\/(.+?)\s*\(\s*\d+?\): (.*)/; // sample line is "11-23 12:39:07.310 1584 1597 I art : Background sticky concurrent mark sweep GC freed 21966(1780KB) AllocSpace objects, 4(80KB) LOS objects, 77% free, 840KB/3MB, paused 4.018ms total 158.629ms" // or '12-28 10:45:08.020 3329 3329 W chromium: [WARNING:data_reduction_proxy_settings.cc(328)] SPDY proxy OFF at startup' AndroidLogFilter.API_LEVEL_23_LINE_REGEX = /.+?\s+?(?:[A-Z]\s+?)([A-Za-z \.]+?)\s*?\: (.*)/; yok_1.injector.register("androidLogFilter", AndroidLogFilter); //# sourceMappingURL=android-log-filter.js.map