From 692faba4129096ab9750c6fcda9b741716b034fe Mon Sep 17 00:00:00 2001 From: "Kristian D. Dimitrov" Date: Tue, 3 Oct 2017 20:03:38 +0300 Subject: [PATCH 1/4] Fix iOS11 Simulator logs --- lib/common | 2 +- lib/services/ios-log-filter.ts | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/common b/lib/common index 418ef567ad..acb47bc335 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit 418ef567ada3204519e06b8ed1a03f5c5e44613a +Subproject commit acb47bc3350c090ffa0358e2ac8852a8ddc20444 diff --git a/lib/services/ios-log-filter.ts b/lib/services/ios-log-filter.ts index fde1997d3a..ac5a63f1f0 100644 --- a/lib/services/ios-log-filter.ts +++ b/lib/services/ios-log-filter.ts @@ -16,7 +16,7 @@ export class IOSLogFilter extends iOSLogFilterBase.IOSLogFilter implements Mobil public filterData(data: string, logLevel: string, pid?: string): string { data = super.filterData(data, logLevel, pid); - if (pid && data && data.indexOf(`[${pid}]`) === -1) { + if (pid && data && data.search(new RegExp(`[\\[\\s]${pid}[\\]\\s]`)) === -1) { return null; } @@ -41,14 +41,16 @@ 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); + const pidIndex = line.indexOf(`[${pid}]`); + const ios11PidIndex = line.indexOf(` ${pid} `); + if (pidIndex > 0 || ios11PidIndex > 0) { + const pidRegex = new RegExp(`.*[\\[\\s]{1}${pid}[\\s\\]]{1}.*?:(?:.*?\\(NativeScript\\) )*`); + 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; From 0e2ee176452f10e052df209f51a8b371278e4363 Mon Sep 17 00:00:00 2001 From: "Kristian D. Dimitrov" Date: Mon, 9 Oct 2017 17:59:13 +0300 Subject: [PATCH 2/4] Fix comments for iOS11 Simulator log. --- lib/common | 2 +- lib/services/ios-log-filter.ts | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/common b/lib/common index acb47bc335..b78fd25407 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit acb47bc3350c090ffa0358e2ac8852a8ddc20444 +Subproject commit b78fd2540736dac44dfeb7a0fd018e7827b7b99f diff --git a/lib/services/ios-log-filter.ts b/lib/services/ios-log-filter.ts index ac5a63f1f0..9fce07587a 100644 --- a/lib/services/ios-log-filter.ts +++ b/lib/services/ios-log-filter.ts @@ -16,7 +16,7 @@ export class IOSLogFilter extends iOSLogFilterBase.IOSLogFilter implements Mobil public filterData(data: string, logLevel: string, pid?: string): string { data = super.filterData(data, logLevel, pid); - if (pid && data && data.search(new RegExp(`[\\[\\s]${pid}[\\]\\s]`)) === -1) { + if (pid && data && data.indexOf(`[${pid}]`) === -1) { return null; } @@ -41,10 +41,8 @@ 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 pidIndex = line.indexOf(`[${pid}]`); - const ios11PidIndex = line.indexOf(` ${pid} `); - if (pidIndex > 0 || ios11PidIndex > 0) { - const pidRegex = new RegExp(`.*[\\[\\s]{1}${pid}[\\s\\]]{1}.*?:(?:.*?\\(NativeScript\\) )*`); + 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"; From 0c4bd3e70813e4cc5e4b19769f9f03c923868bdf Mon Sep 17 00:00:00 2001 From: "Kristian D. Dimitrov" Date: Thu, 12 Oct 2017 15:33:35 +0300 Subject: [PATCH 3/4] Add tests and fix comments iOS11 Simulator log --- lib/services/ios-log-filter.ts | 2 +- test/services/ios-log-filter.ts | 83 ++++++++++++++++++++++++++++++++- 2 files changed, 82 insertions(+), 3 deletions(-) diff --git a/lib/services/ios-log-filter.ts b/lib/services/ios-log-filter.ts index 9fce07587a..f8f965cbbe 100644 --- a/lib/services/ios-log-filter.ts +++ b/lib/services/ios-log-filter.ts @@ -42,7 +42,7 @@ export class IOSLogFilter extends iOSLogFilterBase.IOSLogFilter implements Mobil // CONSOLE LOG file:///location:row:column: if (pid) { if (line.indexOf(`[${pid}]: `) !== -1) { - const pidRegex = new RegExp(`^.*[\\[]${pid}[\\]]:\\s(?:\\(NativeScript\\)\\s)?`); + const pidRegex = new RegExp(`^.*\\[${pid}\\]:\\s(?:\\(NativeScript\\)\\s)?`); line = line.replace(pidRegex, "").trim(); this.getOriginalFileLocation(line); result += this.getOriginalFileLocation(line) + "\n"; 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", ""]; From a9a73a4f6e35c7f7f5e59ce8b239ee19a3040152 Mon Sep 17 00:00:00 2001 From: "Kristian D. Dimitrov" Date: Fri, 13 Oct 2017 15:08:29 +0300 Subject: [PATCH 4/4] Update ios-sim-portable to 3.2.0 --- lib/common | 2 +- npm-shrinkwrap.json | 36 ++++++++++++++++++------------------ package.json | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/common b/lib/common index b78fd25407..d20d42dbd4 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit b78fd2540736dac44dfeb7a0fd018e7827b7b99f +Subproject commit d20d42dbd4bd04715de9725c811534448f3c470a 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",