diff --git a/lib/common b/lib/common index 418ef567ad..d20d42dbd4 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit 418ef567ada3204519e06b8ed1a03f5c5e44613a +Subproject commit d20d42dbd4bd04715de9725c811534448f3c470a diff --git a/lib/services/ios-log-filter.ts b/lib/services/ios-log-filter.ts index fde1997d3a..f8f965cbbe 100644 --- a/lib/services/ios-log-filter.ts +++ b/lib/services/ios-log-filter.ts @@ -41,14 +41,14 @@ export class IOSLogFilter extends iOSLogFilterBase.IOSLogFilter implements Mobil // This code removes unnecessary information from log messages. The output looks like: // CONSOLE LOG file:///location:row:column: if (pid) { - const searchString = "[" + pid + "]: "; - const pidIndex = line.indexOf(searchString); - if (pidIndex > 0) { - line = line.substring(pidIndex + searchString.length, line.length); + if (line.indexOf(`[${pid}]: `) !== -1) { + const pidRegex = new RegExp(`^.*\\[${pid}\\]:\\s(?:\\(NativeScript\\)\\s)?`); + line = line.replace(pidRegex, "").trim(); this.getOriginalFileLocation(line); result += this.getOriginalFileLocation(line) + "\n"; - continue; } + + continue; } if (skipLastLine && i === lines.length - 1 && lines.length > 1) { this.partialLine = line; diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 08269d3e97..dfd7612404 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -2144,13 +2144,6 @@ } } }, - "string_decoder": { - "version": "1.0.1", - "bundled": true, - "requires": { - "safe-buffer": "5.0.1" - } - }, "string-width": { "version": "1.0.2", "bundled": true, @@ -2160,6 +2153,13 @@ "strip-ansi": "3.0.1" } }, + "string_decoder": { + "version": "1.0.1", + "bundled": true, + "requires": { + "safe-buffer": "5.0.1" + } + }, "stringstream": { "version": "0.0.5", "bundled": true, @@ -2945,9 +2945,9 @@ } }, "ios-sim-portable": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/ios-sim-portable/-/ios-sim-portable-3.1.3.tgz", - "integrity": "sha1-B6UWaabdwSP/m/ER3nPXD4kVyew=", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ios-sim-portable/-/ios-sim-portable-3.2.0.tgz", + "integrity": "sha1-ABhIcXGtq5LhreCxgtNLb64wFiY=", "requires": { "bplist-parser": "https://github.com/telerik/node-bplist-parser/tarball/master", "colors": "0.6.2", @@ -4739,14 +4739,6 @@ } } }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha1-D8Z9fBQYJd6UKC3VNr7GubzoYKs=", - "requires": { - "safe-buffer": "5.1.1" - } - }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", @@ -4762,6 +4754,14 @@ "resolved": "https://registry.npmjs.org/string.prototype.codepointat/-/string.prototype.codepointat-0.2.0.tgz", "integrity": "sha1-aybpvTr8qnvjtCabUm3huCAArHg=" }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha1-D8Z9fBQYJd6UKC3VNr7GubzoYKs=", + "requires": { + "safe-buffer": "5.1.1" + } + }, "stringstream": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", diff --git a/package.json b/package.json index 22d32443a4..b6f852f8a5 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "inquirer": "0.9.0", "ios-device-lib": "0.4.10", "ios-mobileprovision-finder": "1.0.10", - "ios-sim-portable": "3.1.3", + "ios-sim-portable": "3.2.0", "lockfile": "1.0.3", "lodash": "4.13.1", "log4js": "1.0.1", diff --git a/test/services/ios-log-filter.ts b/test/services/ios-log-filter.ts index eba20f5ffe..d6d5e4c77f 100644 --- a/test/services/ios-log-filter.ts +++ b/test/services/ios-log-filter.ts @@ -20,6 +20,7 @@ function createTestInjector(): IInjector { describe("iOSLogFilter", () => { let testInjector: IInjector; let logFilter: Mobile.IPlatformLogFilter; + const pid = "52946"; const testData = [ { version: 9, @@ -46,10 +47,72 @@ describe("iOSLogFilter", () => { "CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3472:32: EXCEPTION: Uncaught (in promise): Error: CUSTOM EXCEPTION", "CONSOLE LOG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG", "" + ], + simulator: [ + "Aug 22 10:59:20 MCSOFAPPBLD TestApp[52946]: CONSOLE LOG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG", + "Aug 22 10:59:20 MCSOFAPPBLD TestApp[52946]: CONSOLE DEBUG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG", + "Aug 22 10:59:20 MCSOFAPPBLD TestApp[11111]: CONSOLE DEBUG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG" + ], + simulatorExpectedArr: [ + "CONSOLE LOG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG", + "CONSOLE DEBUG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG", + "" + ] + }, { + version: 10, + originalDataArr: [ + "May 24 15:54:52 Dragons-iPhone apsd(PersistentConnection)[90] : 2017-05-24 15:54:52 +0300 apsd[90]: performing call back", + "May 24 15:54:52 Dragons-iPhone NativeScript250(NativeScript)[356] : CONSOLE LOG file:///app/modules/homeView/homeView.component.js:13:24: CUSTOM CONSOLE LOG", + "May 24 15:54:52 Dragons-iPhone NativeScript250(NativeScript)[356] : CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3472:32: EXCEPTION: Uncaught (in promise): Error: CUSTOM EXCEPTION", + " May 24 15:54:52 Dragons-iPhone NativeScript250(NativeScript)[356] : CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3477:36: ORIGINAL STACKTRACE:", + " May 24 15:54:52 Dragons-iPhone NativeScript250(NativeScript)[356] : CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3478:36: resolvePromise@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:416:40", + "resolvePromise@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:401:31", + "file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:449:31", + "invokeTask@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:223:42", + "onInvokeTask@file:///app/tns_modules/@angular/core/bundles/core.umd.js:4382:51", + "invokeTask@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:222:54", + "runTask@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:123:57", + "drainMicroTaskQueue@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:355:42", + "promiseReactionJob@[native code]", + "UIApplicationMain@[native code]", + "start@file:///app/tns_modules/tns-core-modules/application/application.js:251:26", + "bootstrapApp@file:///app/tns_module", + "Aug 22 10:59:20 MCSOFAPPBLD TestApp[52946]: CONSOLE LOG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG", + "" + ], + infoExpectedArr: [ + null, + "CONSOLE LOG file:///app/modules/homeView/homeView.component.js:13:24: CUSTOM CONSOLE LOG", + "CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3472:32: EXCEPTION: Uncaught (in promise): Error: CUSTOM EXCEPTION", + "CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3477:36: ORIGINAL STACKTRACE:", + "CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3478:36: resolvePromise@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:416:40", + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + "CONSOLE LOG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG", + "" + ], + simulator: [ + "Aug 22 10:59:20 MCSOFAPPBLD TestApp[52946]: CONSOLE LOG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG", + "Aug 22 10:59:20 MCSOFAPPBLD TestApp[52946]: CONSOLE DEBUG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG", + "Aug 22 10:59:20 MCSOFAPPBLD TestApp[11111]: CONSOLE DEBUG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG" + ], + simulatorExpectedArr: [ + "CONSOLE LOG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG", + "CONSOLE DEBUG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG", + "" ] }, { - version: 10, + version: 11, originalDataArr: [ "May 24 15:54:52 Dragons-iPhone apsd(PersistentConnection)[90] : 2017-05-24 15:54:52 +0300 apsd[90]: performing call back", "May 24 15:54:52 Dragons-iPhone NativeScript250(NativeScript)[356] : CONSOLE LOG file:///app/modules/homeView/homeView.component.js:13:24: CUSTOM CONSOLE LOG", @@ -89,6 +152,16 @@ describe("iOSLogFilter", () => { null, "CONSOLE LOG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG", "" + ], + simulator: [ + "2017-10-09 13:34:38.527844+0300 localhost cliapp[52946]: (NativeScript) CONSOLE LOG file:///app/main-view-model.js:18:20: Test Console", + "2017-10-09 13:34:38.527844+0300 localhost cliapp[52946]: (NativeScript) CONSOLE DEBUG file:///app/main-view-model.js:18:20: Test Console", + "Aug 22 10:59:20 MCSOFAPPBLD TestApp[11111]: CONSOLE DEBUG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG" + ], + simulatorExpectedArr: [ + "CONSOLE LOG file:///app/main-view-model.js:18:20: Test Console", + "CONSOLE DEBUG file:///app/main-view-model.js:18:20: Test Console", + "" ] } ]; @@ -116,7 +189,13 @@ describe("iOSLogFilter", () => { }); }); - it(`parses data incorrectly when logLevel is ${infoLogLevel} on iOS ${data.version} and all data is passed at once`, () => { + it(`parses data incorrectly when logLevel is ${infoLogLevel} on iOS ${data.version} and all data is passed at once with pid(simulator)`, () => { + const actualData = logFilter.filterData(data.simulator.join("\n"), infoLogLevel, pid); + const actualArr = actualData.split("\n").map(line => line.trim()); + assert.deepEqual(actualArr, data.simulatorExpectedArr); + }); + + it(`parses data incorrectly when logLevel is ${infoLogLevel} on iOS ${data.version} and all data is passed at once and pid is available`, () => { const actualData = logFilter.filterData(data.originalDataArr.join("\n"), infoLogLevel, null); const actualArr = actualData.split("\n").map(line => line.trim()); const expectedArr = ["CONSOLE LOG file:///app/modules/homeView/homeView.component.js:13:24: CUSTOM CONSOLE LOG", ""];