You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: missing logs when __enableVerboseLogging is called
When you call `__enableVerboseLogging()` in your application, runtimes print more messages, which could be used for identifying issues.
In the official version, when you enable this logging in your app, you see some messages in CLI's output of `tns run` command.
However, this has been working by mistake for Android as CLI does not expect to show these messages, as their category is `TNS.Native` or `TNS.Java`. As CLI does not match these categories, it check if the message contains any of the supported categories. Some of the messages have `JS` in the strings, for example:
```
02-04 15:54:55.101 6047 6047 D TNS.Java: Platform.CallJSMethod: calling js method onActivityStarted with javaObjectID 1 type=com.tns.gen.android.app.Application_ActivityLifecycleCallbacks
02-04 15:54:55.101 6047 6047 D TNS.Native: CallJSMethodNative called javaObjectID=1
```
This led to CLI showing the messages.
After fixing CLI to show only the supported categories (in a previous commit), CLI no longer shows these messages. To show them, add `TNS.Native` and `TNS.Java` categories to supported ones.
Of course, this leads to another issue - during start of application (init of Android Runtime), the verbose logging is enabled by default and now we always show messages:
```
07-25 06:36:38.400 3714 3714 I TNS.Native: NativeScript Runtime Version 5.1.0, commit 4497f43b69cb57ce65ece2aac5b98b2010f85857
07-25 06:36:38.406 8183 8183 D TNS.Native: JNI_ONLoad
07-25 06:36:38.408 8183 8183 D TNS.Native: JNI_ONLoad END
07-25 06:36:38.534 8183 8183 D TNS.Native: V8 version 6.9.427.23
07-25 06:36:38.675 8183 8183 D TNS.Native: lenNodes=66492, lenNames=775380, lenValues=899324
07-25 06:36:38.675 8183 8183 D TNS.Native: time=24
```
As these messages are printed on every Android Runtime Initialization, we do not want to flood the output in CLI. So, we'll introduce a new category in the Android Runtime Logging - `TNS.Runtime`. We need it to print the mentioned messages, as there's no way to enable the verboseLogging before initializing the runtime.
CLI will filter these messages and will not show them.
// Messages with category TNS.Native and TNS.Java will be printed by runtime to Logcat only when `__enableVerboseLogging()` is called in the application.
{input: "W/art ( 4502): Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable",output: null},
100
100
{input: "I/art ( 4502): Rejecting re-init on previously-failed class java.lang.Class<android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>",output: null},
101
101
{input: "I/art ( 4502): Rejecting re-init on previously-failed class java.lang.Class<android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>",output: null},
{input: "07-25 06:36:22.590 8141 8141 D TNS.Native: time=1",output: "TNS.Native: time=1"},
121
121
{input: "07-25 06:36:23.065 739 760 I Choreographer: Skipped 54 frames! The application may be doing too much work on its main thread.",output: null},
122
122
{input: "07-25 06:36:23.149 8141 8141 W art : Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable",output: null},
123
123
{input: "07-25 06:36:23.298 8141 8141 D : HostConnection::get() New Host Connection established 0xd3916970, tid 8141",output: null},
{input: "02-01 13:29:23.067 8141 8141 D TNS.Native: time=2",output: "TNS.Native: time=2"},
236
236
{input: "02-01 13:29:23.155 2288 2390 D EGL_emulation: eglMakeCurrent: 0xa037ba00: ver 2 0 (tinfo 0x92b47100)",output: null},
237
237
{input: "02-01 13:29:23.450 8141 8141 W art : Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable",output: null},
238
238
{input: "02-01 13:29:23.576 8141 4663 I art : Background sticky concurrent mark sweep GC freed 20657(1509KB) AllocSpace objects, 7(140KB) LOS objects, 0% free, 11MB/11MB, paused 12.708ms total 102.843ms",output: null},
{input: "02-01 13:29:23.994 8141 8141 I art : at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)",output: null},
290
290
{input: "02-01 13:29:23.994 8141 8141 I art : at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:866)",output: null},
291
291
{input: "02-01 13:29:23.994 8141 8141 I art : at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:756)",output: null},
{input: "02-04 15:54:54.440 8141 8141 D TNS.Native: createJSInstanceNative class com/tns/NativeScriptActivity",output: "TNS.Native: createJSInstanceNative class com/tns/NativeScriptActivity"},
{input: "02-04 15:54:54.440 8141 8141 D TNS.Java: JSInstance for class com.tns.NativeScriptActivity created with overrides",output: "TNS.Java: JSInstance for class com.tns.NativeScriptActivity created with overrides"},
296
+
{input: "02-04 15:54:54.448 8141 8141 D TNS.Java: Platform.CallJSMethod: calling js method onCreate with javaObjectID 3 type=com.tns.NativeScriptActivity",output: "TNS.Java: Platform.CallJSMethod: calling js method onCreate with javaObjectID 3 type=com.tns.NativeScriptActivity"},
297
+
{input: "02-04 15:54:54.449 8141 8141 D TNS.Native: CallJSMethodNative called javaObjectID=3",output: "TNS.Native: CallJSMethodNative called javaObjectID=3"},
298
+
{input: "02-04 15:54:54.449 8141 8141 D TNS.Native: CallJSMethodNative called jsObject=335940",output: "TNS.Native: CallJSMethodNative called jsObject=335940"},
299
+
{input: "02-04 15:54:54.516 8141 8141 D TNS.Java: Platform.CallJSMethod: calling js method onActivityCreated with javaObjectID 1 type=com.tns.gen.android.app.Application_ActivityLifecycleCallbacks",output: "TNS.Java: Platform.CallJSMethod: calling js method onActivityCreated with javaObjectID 1 type=com.tns.gen.android.app.Application_ActivityLifecycleCallbacks"},
300
+
{input: "02-04 15:54:54.516 8141 8141 D TNS.Native: CallJSMethodNative called javaObjectID=1",output: "TNS.Native: CallJSMethodNative called javaObjectID=1"},
301
+
{input: "02-04 15:54:54.516 8141 8141 D TNS.Native: CallJSMethodNative called jsObject=572643",output: "TNS.Native: CallJSMethodNative called jsObject=572643"},
{input: "02-04 15:54:54.630 8141 8141 D TNS.Native: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1120)",output: "TNS.Native: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1120)"},
304
+
{input: "02-04 15:54:54.630 8141 8141 D TNS.Native: com.tns.Runtime.callJSMethodImpl(Runtime.java:1000)",output: "TNS.Native: com.tns.Runtime.callJSMethodImpl(Runtime.java:1000)"},
305
+
{input: "02-04 15:54:54.630 8141 8141 D TNS.Native: com.tns.Runtime.callJSMethod(Runtime.java:987)",output: "TNS.Native: com.tns.Runtime.callJSMethod(Runtime.java:987)"},
306
+
{input: "02-04 15:54:54.630 8141 8141 D TNS.Native: com.tns.Runtime.callJSMethod(Runtime.java:967)",output: "TNS.Native: com.tns.Runtime.callJSMethod(Runtime.java:967)"},
307
+
{input: "02-04 15:54:54.630 8141 8141 D TNS.Native: com.tns.Runtime.callJSMethod(Runtime.java:959)",output: "TNS.Native: com.tns.Runtime.callJSMethod(Runtime.java:959)"},
308
+
{input: "02-04 15:54:55.100 8141 8141 D TNS.Java: Platform.CallJSMethod: calling js method onStart with javaObjectID 3 type=com.tns.NativeScriptActivity",output: "TNS.Java: Platform.CallJSMethod: calling js method onStart with javaObjectID 3 type=com.tns.NativeScriptActivity"},
309
+
{input: "02-04 15:54:55.100 8141 8141 D TNS.Native: CallJSMethodNative called javaObjectID=3",output: "TNS.Native: CallJSMethodNative called javaObjectID=3"},
310
+
{input: "02-04 15:54:55.100 8141 8141 D TNS.Native: CallJSMethodNative called jsObject=335940",output: "TNS.Native: CallJSMethodNative called jsObject=335940"},
311
+
{input: "02-04 15:54:55.101 8141 8141 D TNS.Java: Platform.CallJSMethod: calling js method onActivityStarted with javaObjectID 1 type=com.tns.gen.android.app.Application_ActivityLifecycleCallbacks",output: "TNS.Java: Platform.CallJSMethod: calling js method onActivityStarted with javaObjectID 1 type=com.tns.gen.android.app.Application_ActivityLifecycleCallbacks"},
312
+
{input: "02-04 15:54:55.101 8141 8141 D TNS.Native: CallJSMethodNative called javaObjectID=1",output: "TNS.Native: CallJSMethodNative called javaObjectID=1"},
313
+
{input: "02-04 15:54:55.101 8141 8141 D TNS.Native: CallJSMethodNative called jsObject=572643",output: "TNS.Native: CallJSMethodNative called jsObject=572643"},
314
+
{input: "02-04 15:54:55.180 8141 8141 D TNS.Java: Platform.CallJSMethod: calling js method onActivityResumed with javaObjectID 1 type=com.tns.gen.android.app.Application_ActivityLifecycleCallbacks",output: "TNS.Java: Platform.CallJSMethod: calling js method onActivityResumed with javaObjectID 1 type=com.tns.gen.android.app.Application_ActivityLifecycleCallbacks"},
315
+
{input: "02-04 15:54:55.180 8141 8141 D TNS.Native: CallJSMethodNative called javaObjectID=1",output: "TNS.Native: CallJSMethodNative called javaObjectID=1"},
316
+
{input: "02-04 15:54:55.180 8141 8141 D TNS.Native: CallJSMethodNative called jsObject=572643",output: "TNS.Native: CallJSMethodNative called jsObject=572643"},
317
+
{input: "02-04 15:54:55.216 8141 8141 D TNS.Java: Platform.CallJSMethod: calling js method onViewAttachedToWindow with javaObjectID 75 type=com.tns.gen.java.lang.Object_frame_29_36_AttachListener",output: "TNS.Java: Platform.CallJSMethod: calling js method onViewAttachedToWindow with javaObjectID 75 type=com.tns.gen.java.lang.Object_frame_29_36_AttachListener"},
318
+
{input: "02-04 15:54:55.216 8141 8141 D TNS.Native: CallJSMethodNative called javaObjectID=75",output: "TNS.Native: CallJSMethodNative called javaObjectID=75"},
0 commit comments