From be1e737a7457d4e35eda76619369a52b88d0dcab Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Mon, 22 May 2023 18:07:01 +0200 Subject: [PATCH] fix(logs): correctly trim ios logs + fix tests --- .../unit-tests/mobile/device-log-provider.ts | 526 +++++++++--------- lib/services/ios-log-filter.ts | 2 +- 2 files changed, 258 insertions(+), 270 deletions(-) diff --git a/lib/common/test/unit-tests/mobile/device-log-provider.ts b/lib/common/test/unit-tests/mobile/device-log-provider.ts index a1a0a76e0c..4ff3b3da1a 100644 --- a/lib/common/test/unit-tests/mobile/device-log-provider.ts +++ b/lib/common/test/unit-tests/mobile/device-log-provider.ts @@ -19,6 +19,7 @@ import { IProjectData } from "../../../../definitions/project"; import { IInjector } from "../../../definitions/yok"; import * as _ from "lodash"; import { IFileSystem } from "../../../declarations"; +import { color } from "../../../../color"; const deviceIdentifier = "deviceIdentifier"; let runtimeVersion = "6.1.0"; @@ -94,8 +95,18 @@ describe("deviceLogProvider", () => { let deviceLogProvider: Mobile.IDeviceLogProvider; const assertData = (actual: string, expected: string) => { - const actualFixed = actual.replace(/\r\n/g, "\n").replace(/\\/g, "/"); - const expectedFixed = expected.replace(/\r\n/g, "\n").replace(/\\/g, "/"); + const actualFixed = actual + .replaceAll(/\r\n/g, "\n") + .replaceAll(/\\/g, "/") + .replaceAll(/\t/g, color.dim("→")) + .replaceAll(/ /g, color.dim("⋅")) + .replaceAll("\n", color.dim("↵") + "\n"); + const expectedFixed = expected + .replaceAll(/\r\n/g, "\n") + .replaceAll(/\\/g, "/") + .replaceAll(/\t/g, color.dim("→")) + .replaceAll(/ /g, color.dim("⋅")) + .replaceAll("\n", color.dim("↵") + "\n"); assert.equal(actualFixed, expectedFixed); }; @@ -117,9 +128,8 @@ describe("deviceLogProvider", () => { } logger = testInjector.resolve("logger"); - deviceLogProvider = testInjector.resolve( - "deviceLogProvider" - ); + deviceLogProvider = + testInjector.resolve("deviceLogProvider"); deviceLogProvider.setProjectDirForDevice( "deviceIdentifier", "dir_with_runtime_6.1.0" @@ -161,7 +171,7 @@ describe("deviceLogProvider", () => { ); assertData( logger.output, - "JS: HMR: Hot Module Replacement Enabled. Waiting for signal.\n" + "HMR: Hot Module Replacement Enabled. Waiting for signal.\n" ); }); @@ -181,19 +191,19 @@ describe("deviceLogProvider", () => { 08-22 15:32:03.145 25038 25038 I JS : ==== object dump end ====`); assertData( logger.output, - `JS: ==== object dump start ==== -JS: level0_0: { -JS: "level1_0": { -JS: "level2": "value" -JS: }, -JS: "level1_1": { -JS: "level2": "value2" -JS: } -JS: } -JS: level0_1: { -JS: "level1_0": "value3" -JS: } -JS: ==== object dump end ====\n` + `==== object dump start ==== +level0_0: { + "level1_0": { + "level2": "value" + }, + "level1_1": { + "level2": "value2" + } +} +level0_1: { + "level1_0": "value3" +} +==== object dump end ====\n` ); }); @@ -204,10 +214,10 @@ JS: ==== object dump end ====\n` 08-22 15:32:03.145 25038 25038 I JS : console.log`); assertData( logger.output, - `JS: multiline -JS: message -JS: from -JS: console.log\n` + `multiline + message + from + console.log\n` ); }); @@ -219,11 +229,11 @@ JS: console.log\n` 08-22 15:32:03.145 25038 25038 E JS : at ClickListenerImpl.onClick (file:///data/data/org.nativescript.appTestLogs/files/app/vendor.js:14608:23)`); assertData( logger.output, - `JS: Trace: console.trace onTap -JS: at viewModel.onTap file: app/main-view-model.js:39:0 -JS: at push.../node_modules/tns-core-modules/data/observable/observable.js.Observable.notify file: node_modules/tns-core-modules/data/observable/observable.js:107:0 -JS: at push.../node_modules/tns-core-modules/data/observable/observable.js.Observable._emit file: node_modules/tns-core-modules/data/observable/observable.js:127:0 -JS: at ClickListenerImpl.onClick file: node_modules/tns-core-modules/ui/button/button.js:29:0\n` + `Trace: console.trace onTap +at viewModel.onTap file: app/main-view-model.js:39:0 +at push.../node_modules/tns-core-modules/data/observable/observable.js.Observable.notify file: node_modules/tns-core-modules/data/observable/observable.js:107:0 +at push.../node_modules/tns-core-modules/data/observable/observable.js.Observable._emit file: node_modules/tns-core-modules/data/observable/observable.js:127:0 +at ClickListenerImpl.onClick file: node_modules/tns-core-modules/ui/button/button.js:29:0\n` ); }); @@ -231,7 +241,7 @@ JS: at ClickListenerImpl.onClick file: node_modules/tns-core-modules/ui/button/b logDataForAndroid( "08-22 15:32:03.145 25038 25038 I JS : console.time: 9603.00ms" ); - assertData(logger.output, "JS: console.time: 9603.00ms\n"); + assertData(logger.output, "console.time: 9603.00ms\n"); }); it("when an error is thrown, correct callstack is printed", async () => { @@ -340,7 +350,7 @@ System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)\n` ); assertData( logger.output, - "JS: HMR: Hot Module Replacement Enabled. Waiting for signal.\n" + "HMR: Hot Module Replacement Enabled. Waiting for signal.\n" ); }); @@ -360,19 +370,19 @@ System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)\n` 08-23 16:16:06.570 25038 25038 I JS : ==== object dump end ====`); assertData( logger.output, - `JS: ==== object dump start ==== -JS: level0_0: { -JS: "level1_0": { -JS: "level2": "value" -JS: }, -JS: "level1_1": { -JS: "level2": "value2" -JS: } -JS: } -JS: level0_1: { -JS: "level1_0": "value3" -JS: } -JS: ==== object dump end ====\n` + `==== object dump start ==== +level0_0: { + "level1_0": { + "level2": "value" + }, + "level1_1": { + "level2": "value2" + } +} +level0_1: { + "level1_0": "value3" +} +==== object dump end ====\n` ); }); @@ -383,10 +393,10 @@ JS: ==== object dump end ====\n` 08-23 16:16:06.570 25038 25038 I JS : console.log`); assertData( logger.output, - `JS: multiline -JS: message -JS: from -JS: console.log\n` + `multiline + message + from + console.log\n` ); }); @@ -398,11 +408,11 @@ JS: console.log\n` 08-23 16:16:06.571 25038 25038 E JS : at ClickListenerImpl.onClick (file:///data/data/org.nativescript.appTestLogs/files/app/vendor.js:14608:23)`); assertData( logger.output, - `JS: Trace: console.trace onTap -JS: at viewModel.onTap (file: app/main-view-model.js:39:0) -JS: at push.../node_modules/tns-core-modules/data/observable/observable.js.Observable.notify (file: node_modules/tns-core-modules/data/observable/observable.js:107:0) -JS: at push.../node_modules/tns-core-modules/data/observable/observable.js.Observable._emit (file: node_modules/tns-core-modules/data/observable/observable.js:127:0) -JS: at ClickListenerImpl.onClick (file: node_modules/tns-core-modules/ui/button/button.js:29:0)\n` + `Trace: console.trace onTap +at viewModel.onTap (file: app/main-view-model.js:39:0) +at push.../node_modules/tns-core-modules/data/observable/observable.js.Observable.notify (file: node_modules/tns-core-modules/data/observable/observable.js:107:0) +at push.../node_modules/tns-core-modules/data/observable/observable.js.Observable._emit (file: node_modules/tns-core-modules/data/observable/observable.js:127:0) +at ClickListenerImpl.onClick (file: node_modules/tns-core-modules/ui/button/button.js:29:0)\n` ); }); @@ -410,7 +420,7 @@ JS: at ClickListenerImpl.onClick (file: node_modules/tns-core-modules/ui/button/ logDataForAndroid( "08-23 16:16:06.571 25038 25038 I JS : console.time: 9510.00ms" ); - assertData(logger.output, "JS: console.time: 9510.00ms\n"); + assertData(logger.output, "console.time: 9510.00ms\n"); }); it("when an error is thrown, correct callstack is printed", async () => { @@ -540,71 +550,66 @@ System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)\n` }); it("console.dir", () => { - logDataForiOS(`Aug 23 14:38:58 mcsofvladimirov appTestLogs[8455]: CONSOLE LOG file:///app/bundle.js:270:20: - ==== object dump start ==== - level0_0: { - "level1_0": { - "level2": "value" - }, - "level1_1": { - "level2": "value2" - } - } - level0_1: { - "level1_0": "value3" - } - ==== object dump end ====`); - assertData( - logger.output, - `CONSOLE LOG file: app/main-view-model.js:20:0 -==== object dump start ==== + const dump = `==== object dump start ==== level0_0: { -"level1_0": { -"level2": "value" -}, -"level1_1": { -"level2": "value2" -} +\t"level1_0": { +\t "level2": "value" +\t}, +\t"level1_1": { +\t\t"level2": "value2" +\t} } level0_1: { -"level1_0": "value3" +\t"level1_0": "value3" } -==== object dump end ====\n` +==== object dump end ====`; + logDataForiOS( + `Aug 23 14:38:58 mcsofvladimirov appTestLogs[8455]: CONSOLE LOG file:///app/bundle.js:270:20:\n${dump}` + ); + assertData( + logger.output, + `CONSOLE LOG file: app/main-view-model.js:20:0\n${dump}\n` ); }); it("multiline console.log statement", () => { - logDataForiOS(`Aug 23 14:38:58 mcsofvladimirov appTestLogs[8455]: CONSOLE LOG file:///app/bundle.js:284:20: multiline - message - from - console.log`); + logDataForiOS( + [ + `Aug 23 14:38:58 mcsofvladimirov appTestLogs[8455]: CONSOLE LOG file:///app/bundle.js:284:20: multiline`, + `\tmessage`, + `\sfrom`, + `\t\sconsole.log`, + ].join("\n") + ); assertData( logger.output, - `CONSOLE LOG file: app/main-view-model.js:34:0 multiline -message -from -console.log\n` + [ + `CONSOLE LOG file: app/main-view-model.js:34:0 multiline`, + `\tmessage`, + `\sfrom`, + `\t\sconsole.log\n`, + ].join("\n") ); }); it("console.trace", async () => { logDataForiOS(`Aug 23 14:38:58 mcsofvladimirov appTestLogs[8455]: CONSOLE TRACE file:///app/bundle.js:289:22: console.trace onTap - 1 onTap@file:///app/bundle.js:289:22 - 2 notify@file:///app/vendor.js:3756:37 - 3 _emit@file:///app/vendor.js:3776:24 - 4 tap@file:///app/vendor.js:15438:24 - 5 UIApplicationMain@[native code] - 6 _start@file:///app/vendor.js:789:26 - 7 run@file:///app/vendor.js:817:11 - 8 @file:///app/bundle.js:155:16 - 9 ./app.js@file:///app/bundle.js:172:34 - 10 __webpack_require__@file:///app/runtime.js:751:34 - 11 checkDeferredModules@file:///app/runtime.js:44:42 - 12 webpackJsonpCallback@file:///app/runtime.js:31:39 - 13 anonymous@file:///app/bundle.js:2:61 - 14 evaluate@[native code] - 15 moduleEvaluation@:1:11 - 16 promiseReactionJob@:1:11`); +1 onTap@file:///app/bundle.js:289:22 +2 notify@file:///app/vendor.js:3756:37 +3 _emit@file:///app/vendor.js:3776:24 +4 tap@file:///app/vendor.js:15438:24 +5 UIApplicationMain@[native code] +6 _start@file:///app/vendor.js:789:26 +7 run@file:///app/vendor.js:817:11 +8 @file:///app/bundle.js:155:16 +9 ./app.js@file:///app/bundle.js:172:34 +10 __webpack_require__@file:///app/runtime.js:751:34 +11 checkDeferredModules@file:///app/runtime.js:44:42 +12 webpackJsonpCallback@file:///app/runtime.js:31:39 +13 anonymous@file:///app/bundle.js:2:61 +14 evaluate@[native code] +15 moduleEvaluation@:1:11 +16 promiseReactionJob@:1:11`); assertData( logger.output, `CONSOLE TRACE file: app/main-view-model.js:39:0 console.trace onTap @@ -745,21 +750,21 @@ Native stack trace: 19 0x10fc91100 JavaScript stack trace: 1 onTap@file: app/main-view-model.js:43:0 -2 notify@file: node_modules/tns-core-modules/data/observable/observable.js:107:0 -3 _emit@file: node_modules/tns-core-modules/data/observable/observable.js:127:0 -4 tap@file: node_modules/tns-core-modules/ui/button/button.js:216:0 -5 UIApplicationMain@[native code] -6 _start@file: node_modules/tns-core-modules/application/application.js:277:0 -7 run@file: node_modules/tns-core-modules/application/application.js:305:0 -8 @file: app/app.js:46:0 -9 ./app.js@file:///app/bundle.js:172:34 -10 __webpack_require__@file: app/webpack/bootstrap:750:0 -11 checkDeferredModules@file: app/webpack/bootstrap:43:0 -12 webpackJsonpCallback@file: app/webpack/bootstrap:30:0 -13 anonymous@file:///app/bundle.js:2:61 -14 evaluate@[native code] -15 moduleEvaluation@[native code] -16 promiseReactionJob@[native code] + 2 notify@file: node_modules/tns-core-modules/data/observable/observable.js:107:0 + 3 _emit@file: node_modules/tns-core-modules/data/observable/observable.js:127:0 + 4 tap@file: node_modules/tns-core-modules/ui/button/button.js:216:0 + 5 UIApplicationMain@[native code] + 6 _start@file: node_modules/tns-core-modules/application/application.js:277:0 + 7 run@file: node_modules/tns-core-modules/application/application.js:305:0 + 8 @file: app/app.js:46:0 + 9 ./app.js@file:///app/bundle.js:172:34 + 10 __webpack_require__@file: app/webpack/bootstrap:750:0 + 11 checkDeferredModules@file: app/webpack/bootstrap:43:0 + 12 webpackJsonpCallback@file: app/webpack/bootstrap:30:0 + 13 anonymous@file:///app/bundle.js:2:61 + 14 evaluate@[native code] + 15 moduleEvaluation@[native code] + 16 promiseReactionJob@[native code] JavaScript error: file: app/main-view-model.js:43:0 JS ERROR Error: Error in onTap NativeScript caught signal 11. @@ -792,17 +797,17 @@ Native Stack: 26 0x10fc91100 JS Stack: 1 UIApplicationMain@[native code] -2 _start@file: node_modules/tns-core-modules/application/application.js:277:0 -3 run@file: node_modules/tns-core-modules/application/application.js:305:0 -4 @file: app/app.js:46:0 -5 ./app.js@file:///app/bundle.js:172:34 -6 __webpack_require__@file: app/webpack/bootstrap:750:0 -7 checkDeferredModules@file: app/webpack/bootstrap:43:0 -8 webpackJsonpCallback@file: app/webpack/bootstrap:30:0 -9 anonymous@file:///app/bundle.js:2:61 -10 evaluate@[native code] -11 moduleEvaluation@:1:11 -12 promiseReactionJob@:1:11\n` + 2 _start@file: node_modules/tns-core-modules/application/application.js:277:0 + 3 run@file: node_modules/tns-core-modules/application/application.js:305:0 + 4 @file: app/app.js:46:0 + 5 ./app.js@file:///app/bundle.js:172:34 + 6 __webpack_require__@file: app/webpack/bootstrap:750:0 + 7 checkDeferredModules@file: app/webpack/bootstrap:43:0 + 8 webpackJsonpCallback@file: app/webpack/bootstrap:30:0 + 9 anonymous@file:///app/bundle.js:2:61 + 10 evaluate@[native code] + 11 moduleEvaluation@:1:11 + 12 promiseReactionJob@:1:11\n` ); }); }); @@ -822,50 +827,45 @@ JS Stack: }); it("console.dir", () => { - logDataForiOS(`2019-08-22 18:21:26.133151+0300 localhost appTestLogs[55619]: (NativeScript) CONSOLE LOG file:///app/bundle.js:270:20: -==== object dump start ==== + const dump = `==== object dump start ==== level0_0: { - "level1_0": { - "level2": "value" - }, - "level1_1": { - "level2": "value2" - } + "level1_0": { + "level2": "value" + }, + "level1_1": { + "level2": "value2" + } } level0_1: { - "level1_0": "value3" + "level1_0": "value3" } -==== object dump end ====`); +==== object dump end ====`; + logDataForiOS( + `2019-08-22 18:21:26.133151+0300 localhost appTestLogs[55619]: (NativeScript) CONSOLE LOG file:///app/bundle.js:270:20:\n${dump}` + ); assertData( logger.output, - `CONSOLE LOG file: app/main-view-model.js:20:0 -==== object dump start ==== -level0_0: { -"level1_0": { -"level2": "value" -}, -"level1_1": { -"level2": "value2" -} -} -level0_1: { -"level1_0": "value3" -} -==== object dump end ====\n` + `CONSOLE LOG file: app/main-view-model.js:20:0\n${dump}\n` ); }); it("multiline console.log statement", () => { - logDataForiOS(`2019-08-22 18:21:26.133260+0300 localhost appTestLogs[55619]: (NativeScript) CONSOLE LOG file:///app/bundle.js:284:20: multiline - message - from - console.log`); + logDataForiOS( + [ + `2019-08-22 18:21:26.133260+0300 localhost appTestLogs[55619]: (NativeScript) CONSOLE LOG file:///app/bundle.js:284:20: multiline`, + `message`, + ` from`, + `console.log`, + ].join("\n") + ); assertData( logger.output, - `CONSOLE LOG file: app/main-view-model.js:34:0 multiline -message -from -console.log\n` + [ + `CONSOLE LOG file: app/main-view-model.js:34:0 multiline`, + `message`, + ` from`, + `console.log\n`, + ].join("\n") ); }); @@ -1121,71 +1121,64 @@ JS Stack: }); it("console.dir", () => { - logDataForiOS(`Aug 23 18:12:39 mcsofvladimirov appTestLogs[29554]: CONSOLE LOG file:///app/bundle.js:270:20: - ==== object dump start ==== - level0_0: { - "level1_0": { - "level2": "value" - }, - "level1_1": { - "level2": "value2" - } - } - level0_1: { - "level1_0": "value3" - } - ==== object dump end ====`); - assertData( - logger.output, - `CONSOLE LOG file: app/main-view-model.js:20:0: -==== object dump start ==== + const dump = `==== object dump start ==== level0_0: { -"level1_0": { -"level2": "value" -}, -"level1_1": { -"level2": "value2" -} + "level1_0": { + "level2": "value" + }, + "level1_1": { + "level2": "value2" + } } level0_1: { -"level1_0": "value3" + "level1_0": "value3" } -==== object dump end ====\n` +==== object dump end ====` + logDataForiOS(`Aug 23 18:12:39 mcsofvladimirov appTestLogs[29554]: CONSOLE LOG file:///app/bundle.js:270:20:\n${dump}`); + assertData( + logger.output, + `CONSOLE LOG file: app/main-view-model.js:20:0:\n${dump}\n` ); }); it("multiline console.log statement", () => { - logDataForiOS(`Aug 23 18:12:39 mcsofvladimirov appTestLogs[29554]: CONSOLE LOG file:///app/bundle.js:284:20: multiline - message - from - console.log`); + logDataForiOS( + [ + `Aug 23 18:12:39 mcsofvladimirov appTestLogs[29554]: CONSOLE LOG file:///app/bundle.js:284:20: multiline`, + `message`, + ` from`, + `console.log`, + ].join("\n") + ); assertData( logger.output, - `CONSOLE LOG file: app/main-view-model.js:34:0: multiline -message -from -console.log\n` + [ + `CONSOLE LOG file: app/main-view-model.js:34:0: multiline`, + `message`, + ` from`, + `console.log\n`, + ].join("\n") ); }); it("console.trace", async () => { logDataForiOS(`Aug 23 18:12:39 mcsofvladimirov appTestLogs[29554]: CONSOLE TRACE file:///app/bundle.js:289:22: console.trace onTap - onTap(file:///app/bundle.js:289:22) - at notify(file:///app/vendor.js:3756:37) - at _emit(file:///app/vendor.js:3776:24) - at tap(file:///app/vendor.js:15438:24) - at UIApplicationMain([native code]) - at _start(file:///app/vendor.js:789:26) - at run(file:///app/vendor.js:817:11) - at file:///app/bundle.js:155:16 - at ./app.js(file:///app/bundle.js:172:34) - at __webpack_require__(file:///app/runtime.js:751:34) - at checkDeferredModules(file:///app/runtime.js:44:42) - at webpackJsonpCallback(file:///app/runtime.js:31:39) - at anonymous(file:///app/bundle.js:2:61) - at evaluate([native code]) - at moduleEvaluation - at promiseReactionJob`); +onTap(file:///app/bundle.js:289:22) +at notify(file:///app/vendor.js:3756:37) +at _emit(file:///app/vendor.js:3776:24) +at tap(file:///app/vendor.js:15438:24) +at UIApplicationMain([native code]) +at _start(file:///app/vendor.js:789:26) +at run(file:///app/vendor.js:817:11) +at file:///app/bundle.js:155:16 +at ./app.js(file:///app/bundle.js:172:34) +at __webpack_require__(file:///app/runtime.js:751:34) +at checkDeferredModules(file:///app/runtime.js:44:42) +at webpackJsonpCallback(file:///app/runtime.js:31:39) +at anonymous(file:///app/bundle.js:2:61) +at evaluate([native code]) +at moduleEvaluation +at promiseReactionJob`); assertData( logger.output, `CONSOLE TRACE file: app/main-view-model.js:39:0: console.trace onTap @@ -1326,21 +1319,21 @@ Native stack trace: 19 0x11085f1e0 JavaScript stack trace: onTap(file: app/main-view-model.js:43:0) -at notify(file: node_modules/tns-core-modules/data/observable/observable.js:107:0) -at _emit(file: node_modules/tns-core-modules/data/observable/observable.js:127:0) -at tap(file: node_modules/tns-core-modules/ui/button/button.js:216:0) -at UIApplicationMain([native code]) -at _start(file: node_modules/tns-core-modules/application/application.js:277:0) -at run(file: node_modules/tns-core-modules/application/application.js:305:0) -at file: app/app.js:46:0 -at ./app.js(file:///app/bundle.js:172:34) -at __webpack_require__(file: app/webpack/bootstrap:750:0) -at checkDeferredModules(file: app/webpack/bootstrap:43:0) -at webpackJsonpCallback(file: app/webpack/bootstrap:30:0) -at anonymous(file:///app/bundle.js:2:61) -at evaluate([native code]) -at moduleEvaluation([native code]) -at promiseReactionJob([native code]) + at notify(file: node_modules/tns-core-modules/data/observable/observable.js:107:0) + at _emit(file: node_modules/tns-core-modules/data/observable/observable.js:127:0) + at tap(file: node_modules/tns-core-modules/ui/button/button.js:216:0) + at UIApplicationMain([native code]) + at _start(file: node_modules/tns-core-modules/application/application.js:277:0) + at run(file: node_modules/tns-core-modules/application/application.js:305:0) + at file: app/app.js:46:0 + at ./app.js(file:///app/bundle.js:172:34) + at __webpack_require__(file: app/webpack/bootstrap:750:0) + at checkDeferredModules(file: app/webpack/bootstrap:43:0) + at webpackJsonpCallback(file: app/webpack/bootstrap:30:0) + at anonymous(file:///app/bundle.js:2:61) + at evaluate([native code]) + at moduleEvaluation([native code]) + at promiseReactionJob([native code]) JavaScript error: file: app/main-view-model.js:43:0: JS ERROR Error: Error in onTap NativeScript caught signal 11. @@ -1373,17 +1366,17 @@ Native Stack: 26 0x11085f1e0 JS Stack: UIApplicationMain([native code]) -at _start(file: node_modules/tns-core-modules/application/application.js:277:0) -at run(file: node_modules/tns-core-modules/application/application.js:305:0) -at file: app/app.js:46:0 -at ./app.js(file:///app/bundle.js:172:34) -at __webpack_require__(file: app/webpack/bootstrap:750:0) -at checkDeferredModules(file: app/webpack/bootstrap:43:0) -at webpackJsonpCallback(file: app/webpack/bootstrap:30:0) -at anonymous(file:///app/bundle.js:2:61) -at evaluate([native code]) -at moduleEvaluation -at promiseReactionJob\n` + at _start(file: node_modules/tns-core-modules/application/application.js:277:0) + at run(file: node_modules/tns-core-modules/application/application.js:305:0) + at file: app/app.js:46:0 + at ./app.js(file:///app/bundle.js:172:34) + at __webpack_require__(file: app/webpack/bootstrap:750:0) + at checkDeferredModules(file: app/webpack/bootstrap:43:0) + at webpackJsonpCallback(file: app/webpack/bootstrap:30:0) + at anonymous(file:///app/bundle.js:2:61) + at evaluate([native code]) + at moduleEvaluation + at promiseReactionJob\n` ); }); }); @@ -1403,50 +1396,45 @@ at promiseReactionJob\n` }); it("console.dir", () => { - logDataForiOS(`2019-08-23 17:08:45.217971+0300 localhost appTestLogs[21053]: (NativeScript) CONSOLE LOG file:///app/bundle.js:270:20: -==== object dump start ==== + const dump = `==== object dump start ==== level0_0: { - "level1_0": { - "level2": "value" - }, - "level1_1": { - "level2": "value2" - } + "level1_0": { + "level2": "value" + }, + "level1_1": { + "level2": "value2" + } } level0_1: { - "level1_0": "value3" + "level1_0": "value3" } -==== object dump end ====`); +==== object dump end ====`; + logDataForiOS( + `2019-08-23 17:08:45.217971+0300 localhost appTestLogs[21053]: (NativeScript) CONSOLE LOG file:///app/bundle.js:270:20:\n${dump}` + ); assertData( logger.output, - `CONSOLE LOG file: app/main-view-model.js:20:0: -==== object dump start ==== -level0_0: { -"level1_0": { -"level2": "value" -}, -"level1_1": { -"level2": "value2" -} -} -level0_1: { -"level1_0": "value3" -} -==== object dump end ====\n` + `CONSOLE LOG file: app/main-view-model.js:20:0:\n${dump}\n` ); }); it("multiline console.log statement", () => { - logDataForiOS(`2019-08-23 17:08:45.218519+0300 localhost appTestLogs[21053]: (NativeScript) CONSOLE LOG file:///app/bundle.js:284:20: multiline - message - from - console.log`); + logDataForiOS( + [ + `2019-08-23 17:08:45.218519+0300 localhost appTestLogs[21053]: (NativeScript) CONSOLE LOG file:///app/bundle.js:284:20: multiline`, + `message`, + ` from`, + `console.log`, + ].join("\n") + ); assertData( logger.output, - `CONSOLE LOG file: app/main-view-model.js:34:0: multiline -message -from -console.log\n` + [ + `CONSOLE LOG file: app/main-view-model.js:34:0: multiline`, + `message`, + ` from`, + `console.log\n`, + ].join("\n") ); }); diff --git a/lib/services/ios-log-filter.ts b/lib/services/ios-log-filter.ts index 1359cce856..04f58146dc 100644 --- a/lib/services/ios-log-filter.ts +++ b/lib/services/ios-log-filter.ts @@ -10,7 +10,7 @@ export class IOSLogFilter implements Mobile.IPlatformLogFilter { // This: "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:" // Becomes: CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3477:36: ORIGINAL STACKTRACE: protected infoFilterRegex = new RegExp( - `^.*(?::|:|:|\\(NativeScript\\)|${this.appOutputRegex.source}:){1}` + `^.*(?::[ \t]?|:[ \t]?|:[ \t]?|\\(NativeScript\\)[ \t]?|${this.appOutputRegex.source}:[ \t]?){1}` ); // Used to post filter messages that slip through but are not coming from NativeScript itself.