Skip to content

fix: missing logs when __enableVerboseLogging is called #4334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 4, 2019

Conversation

rosen-vladimirov
Copy link
Contributor

@rosen-vladimirov rosen-vladimirov commented Feb 4, 2019

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.

PR Checklist

Related to PR: NativeScript/android#1265

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.
@rosen-vladimirov rosen-vladimirov added bug os: android no-changelog The issue is present only in `next` versions and was not included in official version. labels Feb 4, 2019
@rosen-vladimirov rosen-vladimirov added this to the 5.2.0 milestone Feb 4, 2019
@rosen-vladimirov rosen-vladimirov self-assigned this Feb 4, 2019
@rosen-vladimirov rosen-vladimirov merged commit 889a6d3 into master Feb 4, 2019
@rosen-vladimirov rosen-vladimirov deleted the vladimirov/fix-enable-verbose-logging branch February 4, 2019 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug no-changelog The issue is present only in `next` versions and was not included in official version. os: android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants