Skip to content

Commit 124d236

Browse files
authored
DO NOT MERGE Fix iOS11 Simulator logs (#3145)
Fix iOS11 Simulator logs
1 parent 8179168 commit 124d236

File tree

5 files changed

+106
-27
lines changed

5 files changed

+106
-27
lines changed

lib/services/ios-log-filter.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ export class IOSLogFilter extends iOSLogFilterBase.IOSLogFilter implements Mobil
4141
// This code removes unnecessary information from log messages. The output looks like:
4242
// CONSOLE LOG file:///location:row:column: <actual message goes here>
4343
if (pid) {
44-
const searchString = "[" + pid + "]: ";
45-
const pidIndex = line.indexOf(searchString);
46-
if (pidIndex > 0) {
47-
line = line.substring(pidIndex + searchString.length, line.length);
44+
if (line.indexOf(`[${pid}]: `) !== -1) {
45+
const pidRegex = new RegExp(`^.*\\[${pid}\\]:\\s(?:\\(NativeScript\\)\\s)?`);
46+
line = line.replace(pidRegex, "").trim();
4847
this.getOriginalFileLocation(line);
4948
result += this.getOriginalFileLocation(line) + "\n";
50-
continue;
5149
}
50+
51+
continue;
5252
}
5353
if (skipLastLine && i === lines.length - 1 && lines.length > 1) {
5454
this.partialLine = line;

npm-shrinkwrap.json

+18-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"inquirer": "0.9.0",
4747
"ios-device-lib": "0.4.10",
4848
"ios-mobileprovision-finder": "1.0.10",
49-
"ios-sim-portable": "3.1.3",
49+
"ios-sim-portable": "3.2.0",
5050
"lockfile": "1.0.3",
5151
"lodash": "4.13.1",
5252
"log4js": "1.0.1",

test/services/ios-log-filter.ts

+81-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ function createTestInjector(): IInjector {
2020
describe("iOSLogFilter", () => {
2121
let testInjector: IInjector;
2222
let logFilter: Mobile.IPlatformLogFilter;
23+
const pid = "52946";
2324
const testData = [
2425
{
2526
version: 9,
@@ -46,10 +47,72 @@ describe("iOSLogFilter", () => {
4647
"CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3472:32: EXCEPTION: Uncaught (in promise): Error: CUSTOM EXCEPTION",
4748
"CONSOLE LOG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG",
4849
""
50+
],
51+
simulator: [
52+
"Aug 22 10:59:20 MCSOFAPPBLD TestApp[52946]: CONSOLE LOG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG",
53+
"Aug 22 10:59:20 MCSOFAPPBLD TestApp[52946]: CONSOLE DEBUG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG",
54+
"Aug 22 10:59:20 MCSOFAPPBLD TestApp[11111]: CONSOLE DEBUG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG"
55+
],
56+
simulatorExpectedArr: [
57+
"CONSOLE LOG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG",
58+
"CONSOLE DEBUG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG",
59+
""
60+
]
61+
}, {
62+
version: 10,
63+
originalDataArr: [
64+
"May 24 15:54:52 Dragons-iPhone apsd(PersistentConnection)[90] <Notice>: 2017-05-24 15:54:52 +0300 apsd[90]: <PCDispatchTimer: 0x156ad240> performing call back",
65+
"May 24 15:54:52 Dragons-iPhone NativeScript250(NativeScript)[356] <Notice>: CONSOLE LOG file:///app/modules/homeView/homeView.component.js:13:24: CUSTOM CONSOLE LOG",
66+
"May 24 15:54:52 Dragons-iPhone NativeScript250(NativeScript)[356] <Notice>: CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3472:32: EXCEPTION: Uncaught (in promise): Error: CUSTOM EXCEPTION",
67+
" May 24 15:54:52 Dragons-iPhone NativeScript250(NativeScript)[356] <Notice>: CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3477:36: ORIGINAL STACKTRACE:",
68+
" May 24 15:54:52 Dragons-iPhone NativeScript250(NativeScript)[356] <Notice>: 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",
69+
"resolvePromise@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:401:31",
70+
"file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:449:31",
71+
"invokeTask@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:223:42",
72+
"onInvokeTask@file:///app/tns_modules/@angular/core/bundles/core.umd.js:4382:51",
73+
"invokeTask@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:222:54",
74+
"runTask@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:123:57",
75+
"drainMicroTaskQueue@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:355:42",
76+
"promiseReactionJob@[native code]",
77+
"UIApplicationMain@[native code]",
78+
"start@file:///app/tns_modules/tns-core-modules/application/application.js:251:26",
79+
"bootstrapApp@file:///app/tns_module",
80+
"Aug 22 10:59:20 MCSOFAPPBLD TestApp[52946]: CONSOLE LOG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG",
81+
""
82+
],
83+
infoExpectedArr: [
84+
null,
85+
"CONSOLE LOG file:///app/modules/homeView/homeView.component.js:13:24: CUSTOM CONSOLE LOG",
86+
"CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3472:32: EXCEPTION: Uncaught (in promise): Error: CUSTOM EXCEPTION",
87+
"CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3477:36: ORIGINAL STACKTRACE:",
88+
"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",
89+
null,
90+
null,
91+
null,
92+
null,
93+
null,
94+
null,
95+
null,
96+
null,
97+
null,
98+
null,
99+
null,
100+
"CONSOLE LOG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG",
101+
""
102+
],
103+
simulator: [
104+
"Aug 22 10:59:20 MCSOFAPPBLD TestApp[52946]: CONSOLE LOG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG",
105+
"Aug 22 10:59:20 MCSOFAPPBLD TestApp[52946]: CONSOLE DEBUG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG",
106+
"Aug 22 10:59:20 MCSOFAPPBLD TestApp[11111]: CONSOLE DEBUG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG"
107+
],
108+
simulatorExpectedArr: [
109+
"CONSOLE LOG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG",
110+
"CONSOLE DEBUG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG",
111+
""
49112
]
50113
},
51114
{
52-
version: 10,
115+
version: 11,
53116
originalDataArr: [
54117
"May 24 15:54:52 Dragons-iPhone apsd(PersistentConnection)[90] <Notice>: 2017-05-24 15:54:52 +0300 apsd[90]: <PCDispatchTimer: 0x156ad240> performing call back",
55118
"May 24 15:54:52 Dragons-iPhone NativeScript250(NativeScript)[356] <Notice>: CONSOLE LOG file:///app/modules/homeView/homeView.component.js:13:24: CUSTOM CONSOLE LOG",
@@ -89,6 +152,16 @@ describe("iOSLogFilter", () => {
89152
null,
90153
"CONSOLE LOG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG",
91154
""
155+
],
156+
simulator: [
157+
"2017-10-09 13:34:38.527844+0300 localhost cliapp[52946]: (NativeScript) CONSOLE LOG file:///app/main-view-model.js:18:20: Test Console",
158+
"2017-10-09 13:34:38.527844+0300 localhost cliapp[52946]: (NativeScript) CONSOLE DEBUG file:///app/main-view-model.js:18:20: Test Console",
159+
"Aug 22 10:59:20 MCSOFAPPBLD TestApp[11111]: CONSOLE DEBUG file:///app/home/home-view-model.js:6:20: CUSTOM CONSOLE LOG"
160+
],
161+
simulatorExpectedArr: [
162+
"CONSOLE LOG file:///app/main-view-model.js:18:20: Test Console",
163+
"CONSOLE DEBUG file:///app/main-view-model.js:18:20: Test Console",
164+
""
92165
]
93166
}
94167
];
@@ -116,7 +189,13 @@ describe("iOSLogFilter", () => {
116189
});
117190
});
118191

119-
it(`parses data incorrectly when logLevel is ${infoLogLevel} on iOS ${data.version} and all data is passed at once`, () => {
192+
it(`parses data incorrectly when logLevel is ${infoLogLevel} on iOS ${data.version} and all data is passed at once with pid(simulator)`, () => {
193+
const actualData = logFilter.filterData(data.simulator.join("\n"), infoLogLevel, pid);
194+
const actualArr = actualData.split("\n").map(line => line.trim());
195+
assert.deepEqual(actualArr, data.simulatorExpectedArr);
196+
});
197+
198+
it(`parses data incorrectly when logLevel is ${infoLogLevel} on iOS ${data.version} and all data is passed at once and pid is available`, () => {
120199
const actualData = logFilter.filterData(data.originalDataArr.join("\n"), infoLogLevel, null);
121200
const actualArr = actualData.split("\n").map(line => line.trim());
122201
const expectedArr = ["CONSOLE LOG file:///app/modules/homeView/homeView.component.js:13:24: CUSTOM CONSOLE LOG", ""];

0 commit comments

Comments
 (0)