Skip to content

Commit c3b7318

Browse files
fix: incorrect filtering of Android logs by tag
CLI filters Android logs by PID and by tags. However, in case the PID matches, but we do not find the tag, we may still output the line as we check if it contains the tag anywhere in the content. So, when searching for `JS` tag, we may output the line: ``` 02-01 13:29:23.990 8141 8141 I art : at java.lang.Object com.tns.Runtime.callJSMethod(java.lang.Object, java.lang.String, java.lang.Class, boolean, long, java.lang.Object[]) (Runtime.java:987) ``` Remove this incorrect behavior and rely on the tag filtering.
1 parent e962187 commit c3b7318

File tree

2 files changed

+90
-9
lines changed

2 files changed

+90
-9
lines changed

lib/common/mobile/android/android-log-filter.ts

-5
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ export class AndroidLogFilter implements Mobile.IPlatformLogFilter {
4545
consoleLogMessage = { tag: match[1].trim(), message: match[2] };
4646
}
4747

48-
if (!consoleLogMessage) {
49-
const matchingTag = _.some(acceptedTags, (tag: string) => { return lineText.indexOf(tag) !== -1; });
50-
consoleLogMessage = matchingTag ? { message: lineText } : null;
51-
}
52-
5348
return consoleLogMessage;
5449
}
5550
}

lib/common/test/unit-tests/android-log-filter.ts

+90-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const androidApiLevel23TestData = [
1717
},
1818
{
1919
input: '12-28 10:14:31.460 3593 3593 I BrowserStartupController: Initializing chromium process, singleProcess=true',
20-
output: '12-28 10:14:31.460 3593 3593 I BrowserStartupController: Initializing chromium process, singleProcess=true'
20+
output: null
2121
},
2222
{ input: '12-28 10:14:31.486 3593 3613 W AudioManagerAndroid: Requires BLUETOOTH permission', output: null },
2323
{ input: '12-28 10:14:31.544 3593 3593 D libEGL : loaded /system/lib/egl/libEGL_emulation.so', output: null },
@@ -59,7 +59,7 @@ const androidApiLevel22TestData = [
5959
},
6060
{
6161
input: 'I/BrowserStartupController( 2971): Initializing chromium process, singleProcess=true',
62-
output: 'I/BrowserStartupController( 2971): Initializing chromium process, singleProcess=true'
62+
output: null
6363
},
6464
{ input: 'W/art ( 2971): Attempt to remove local handle scope entry from IRT, ignoring', output: null },
6565
{ input: 'W/AudioManagerAndroid( 2971): Requires BLUETOOTH permission', output: null },
@@ -89,11 +89,33 @@ const androidApiLevel22TestData = [
8989
{
9090
input: 'I/Web Console( 4438): Received Event: deviceready at file:///storage/emulated/0/Icenium/com.telerik.TestApp/js/index.js:48',
9191
output: 'Web Console: Received Event: deviceready at file:///storage/emulated/0/Icenium/com.telerik.TestApp/js/index.js:48'
92-
}
92+
},
93+
{ input: "I/TNS.Native( 4502): NativeScript Runtime Version 5.1.0, commit 4497f43b69cb57ce65ece2aac5b98b2010f85857", output: null },
94+
{ input: "D/TNS.Native( 4502): JNI_ONLoad", output: null },
95+
{ input: "D/TNS.Native( 4502): JNI_ONLoad END", output: null },
96+
{ input: "D/TNS.Native( 4502): V8 version 6.9.427.23", output: null },
97+
{ input: "D/TNS.Native( 4502): lenNodes=79716, lenNames=901566, lenValues=1062800", output: null },
98+
{ input: "D/TNS.Native( 4502): time=1", output: null },
99+
{ 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+
{ input: "I/art ( 4502): Rejecting re-init on previously-failed class java.lang.Class<android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>", output: null },
101+
{ input: "I/art ( 4502): Rejecting re-init on previously-failed class java.lang.Class<android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>", output: null },
102+
{ input: "D/OpenGLRenderer( 4502): Use EGL_SWAP_BEHAVIOR_PRESERVED: true", output: null },
103+
{ input: "D/ ( 4502): HostConnection::get() New Host Connection established 0xa31f1060, tid 4502", output: null },
104+
{ input: "D/Atlas ( 4502): Validating map...", output: null },
105+
{ input: "V/WindowManager( 1542): Adding window Window{22cb1746 u0 org.nativescript.logsss/com.tns.NativeScriptActivity} at 2 of 6 (before Window{3f5d3e9 u0 Starting org.nativescript.logsss})", output: null },
106+
{ input: "D/ ( 4502): HostConnection::get() New Host Connection established 0xa3230f60, tid 4532", output: null },
107+
{ input: "I/OpenGLRenderer( 4502): Initialized EGL, version 1.4", output: null },
108+
{ input: "W/OpenGLRenderer( 4502): Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...", output: null },
109+
{ input: "D/EGL_emulation( 4502): eglCreateContext: 0xa31f2340: maj 2 min 0 rcv 2", output: null },
110+
{ input: "D/EGL_emulation( 4502): eglMakeCurrent: 0xa31f2340: ver 2 0", output: null },
111+
{ input: "D/OpenGLRenderer( 4502): Enabling debug mode 0", output: null },
112+
{ input: "D/ ( 1142): HostConnection::get() New Host Connection established 0xb6038380, tid 4442", output: null },
113+
{ input: "D/EGL_emulation( 4502): eglMakeCurrent: 0xa31f2340: ver 2 0", output: null },
114+
{ input: "I/art ( 4502): Background sticky concurrent mark sweep GC freed 22621(1698KB) AllocSpace objects, 10(183KB) LOS objects, 33% free, 3MB/5MB, paused 5.847ms total 36.229ms", output: null },
93115
];
94116

95117
const androidApiLevel23MapForPid8141 = [
96-
{ input: "--------- beginning of main", output: null },
118+
{ input: "--------- of main", output: null },
97119
{ input: "07-25 06:36:22.590 8141 8141 D TNS.Native: lenNodes=71568, lenNames=824195, lenValues=963214", output: null },
98120
{ input: "07-25 06:36:22.590 8141 8141 D TNS.Native: time=1", output: null },
99121
{ 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 },
@@ -203,6 +225,70 @@ const androidApiLevel23MapForPid8141 = [
203225
{ input: "07-25 06:37:05.212 8244 8244 I TNS.Native: NativeScript Runtime Version 3.1.1, commit 253c76f850b88b0119fda04e413626872f223de5", output: null },
204226
{ input: "07-25 06:37:05.213 8244 8244 D TNS.Native: JNI_ONLoad", output: null },
205227
{ input: "07-25 06:37:05.213 8244 8244 D TNS.Native: JNI_ONLoad END", output: null },
228+
{ input: "02-01 13:29:22.990 8141 8141 I TNS.Native: NativeScript Runtime Version 5.1.0, commit 4497f43b69cb57ce65ece2aac5b98b2010f85857", output: null },
229+
{ input: "02-01 13:29:22.991 8141 8141 D TNS.Native: JNI_ONLoad", output: null },
230+
{ input: "02-01 13:29:22.991 8141 8141 D TNS.Native: JNI_ONLoad END", output: null },
231+
{ input: "02-01 13:29:23.027 1344 1351 D gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 8294400", output: null },
232+
{ input: "02-01 13:29:23.043 1652 1661 I art : Background partial concurrent mark sweep GC freed 975(53KB) AllocSpace objects, 0(0B) LOS objects, 17% free, 18MB/22MB, paused 4.347ms total 122.768ms", output: null },
233+
{ input: "02-01 13:29:23.061 8141 8141 D TNS.Native: V8 version 6.9.427.23", output: null },
234+
{ input: "02-01 13:29:23.067 8141 8141 D TNS.Native: lenNodes=79716, lenNames=901564, lenValues=1062800", output: null },
235+
{ input: "02-01 13:29:23.067 8141 8141 D TNS.Native: time=2", output: null },
236+
{ input: "02-01 13:29:23.155 2288 2390 D EGL_emulation: eglMakeCurrent: 0xa037ba00: ver 2 0 (tinfo 0x92b47100)", output: null },
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+
{ 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 },
239+
{ input: "02-01 13:29:23.988 8141 8141 I art : Rejecting re-init on previously-failed class java.lang.Class<android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;", output: null },
240+
{ input: "02-01 13:29:23.988 8141 8141 I art : at void android.support.v4.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, android.support.v4.view.OnApplyWindowInsetsListener) (ViewCompat.java:2203)", output: null },
241+
{ input: "02-01 13:29:23.988 8141 8141 I art : at android.view.ViewGroup android.support.v7.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:637)", output: null },
242+
{ input: "02-01 13:29:23.988 8141 8141 I art : at void android.support.v7.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)", output: null },
243+
{ input: "02-01 13:29:23.988 8141 8141 I art : at void android.support.v7.app.AppCompatDelegateImpl.setContentView(android.view.View, android.view.ViewGroup$LayoutParams) (AppCompatDelegateImpl.java:475)", output: null },
244+
{ input: "02-01 13:29:23.988 8141 8141 I art : at void android.support.v7.app.AppCompatActivity.setContentView(android.view.View, android.view.ViewGroup$LayoutParams) (AppCompatActivity.java:150)", output: null },
245+
{ input: "02-01 13:29:23.988 8141 8141 I art : at java.lang.Object com.tns.Runtime.callJSMethodNative(int, int, java.lang.String, int, boolean, java.lang.Object[]) (Runtime.java:-2)", output: null },
246+
{ input: "02-01 13:29:23.989 8141 8141 I art : at java.lang.Object com.tns.Runtime.dispatchCallJSMethodNative(int, java.lang.String, boolean, long, java.lang.Class, java.lang.Object[]) (Runtime.java:1120)", output: null },
247+
{ input: "02-01 13:29:23.989 8141 8141 I art : at java.lang.Object com.tns.Runtime.callJSMethodImpl(java.lang.Object, java.lang.String, java.lang.Class, boolean, long, java.lang.Object[]) (Runtime.java:1000)", output: null },
248+
{ input: "02-01 13:29:23.990 8141 8141 I art : at java.lang.Object com.tns.Runtime.callJSMethod(java.lang.Object, java.lang.String, java.lang.Class, boolean, long, java.lang.Object[]) (Runtime.java:987)", output: null },
249+
{ input: "02-01 13:29:23.990 8141 8141 I art : at java.lang.Object com.tns.Runtime.callJSMethod(java.lang.Object, java.lang.String, java.lang.Class, boolean, java.lang.Object[]) (Runtime.java:967)", output: null },
250+
{ input: "02-01 13:29:23.990 8141 8141 I art : at java.lang.Object com.tns.Runtime.callJSMethod(java.lang.Object, java.lang.String, java.lang.Class, java.lang.Object[]) (Runtime.java:959)", output: null },
251+
{ input: "02-01 13:29:23.990 8141 8141 I art : at void com.tns.NativeScriptActivity.onCreate(android.os.Bundle) (NativeScriptActivity.java:18)", output: null },
252+
{ input: "02-01 13:29:23.990 8141 8141 I art : at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6662)", output: null },
253+
{ input: "02-01 13:29:23.990 8141 8141 I art : at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1118)", output: null },
254+
{ input: "02-01 13:29:23.990 8141 8141 I art : at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2599)", output: null },
255+
{ input: "02-01 13:29:23.990 8141 8141 I art : at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2707)", output: null },
256+
{ input: "02-01 13:29:23.990 8141 8141 I art : at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)", output: null },
257+
{ input: "02-01 13:29:23.990 8141 8141 I art : at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1460)", output: null },
258+
{ input: "02-01 13:29:23.990 8141 8141 I art : at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)", output: null },
259+
{ input: "02-01 13:29:23.990 8141 8141 I art : at void android.os.Looper.loop() (Looper.java:154)", output: null },
260+
{ input: "02-01 13:29:23.990 8141 8141 I art : at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6077)", output: null },
261+
{ input: "02-01 13:29:23.990 8141 8141 I art : at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)", output: null },
262+
{ input: "02-01 13:29:23.990 8141 8141 I art : at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:866)", output: null },
263+
{ input: "02-01 13:29:23.991 8141 8141 I art : at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:756)", output: null },
264+
{ input: "02-01 13:29:23.991 8141 8141 I art : Caused by: java.lang.ClassNotFoundException: Didn't find class \"android.view.View$OnUnhandledKeyEventListener\" on path: DexPathList[[zip file \"/data/app / org.nativescript.app1 - 1 / base.apk\"],nativeLibraryDirectories=[/data/app/org.nativescript.app1-1/lib/x86, /data/app/org.nativescript.app1-1/base.apk!/lib/x86, /system/lib, /vendor/lib]]", output: null },
265+
{ input: "02-01 13:29:23.992 8141 8141 I art : at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56)", output: null },
266+
{ input: "02-01 13:29:23.992 8141 8141 I art : at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:380)", output: null },
267+
{ input: "02-01 13:29:23.992 8141 8141 I art : at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)", output: null },
268+
{ input: "02-01 13:29:23.992 8141 8141 I art : at void android.support.v4.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, android.support.v4.view.OnApplyWindowInsetsListener) (ViewCompat.java:2203)", output: null },
269+
{ input: "02-01 13:29:23.992 8141 8141 I art : at android.view.ViewGroup android.support.v7.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:637)", output: null },
270+
{ input: "02-01 13:29:23.992 8141 8141 I art : at void android.support.v7.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)", output: null },
271+
{ input: "02-01 13:29:23.992 8141 8141 I art : at void android.support.v7.app.AppCompatDelegateImpl.setContentView(android.view.View, android.view.ViewGroup$LayoutParams) (AppCompatDelegateImpl.java:475)", output: null },
272+
{ input: "02-01 13:29:23.992 8141 8141 I art : at void android.support.v7.app.AppCompatActivity.setContentView(android.view.View, android.view.ViewGroup$LayoutParams) (AppCompatActivity.java:150)", output: null },
273+
{ input: "02-01 13:29:23.992 8141 8141 I art : at java.lang.Object com.tns.Runtime.callJSMethodNative(int, int, java.lang.String, int, boolean, java.lang.Object[]) (Runtime.java:-2)", output: null },
274+
{ input: "02-01 13:29:23.992 8141 8141 I art : at java.lang.Object com.tns.Runtime.dispatchCallJSMethodNative(int, java.lang.String, boolean, long, java.lang.Class, java.lang.Object[]) (Runtime.java:1120)", output: null },
275+
{ input: "02-01 13:29:23.992 8141 8141 I art : at java.lang.Object com.tns.Runtime.callJSMethodImpl(java.lang.Object, java.lang.String, java.lang.Class, boolean, long, java.lang.Object[]) (Runtime.java:1000)", output: null },
276+
{ input: "02-01 13:29:23.992 8141 8141 I art : at java.lang.Object com.tns.Runtime.callJSMethod(java.lang.Object, java.lang.String, java.lang.Class, boolean, long, java.lang.Object[]) (Runtime.java:987)", output: null },
277+
{ input: "02-01 13:29:23.992 8141 8141 I art : at java.lang.Object com.tns.Runtime.callJSMethod(java.lang.Object, java.lang.String, java.lang.Class, boolean, java.lang.Object[]) (Runtime.java:967)", output: null },
278+
{ input: "02-01 13:29:23.993 8141 8141 I art : at java.lang.Object com.tns.Runtime.callJSMethod(java.lang.Object, java.lang.String, java.lang.Class, java.lang.Object[]) (Runtime.java:959)", output: null },
279+
{ input: "02-01 13:29:23.993 8141 8141 I art : at void com.tns.NativeScriptActivity.onCreate(android.os.Bundle) (NativeScriptActivity.java:18)", output: null },
280+
{ input: "02-01 13:29:23.994 8141 8141 I art : at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6662)", output: null },
281+
{ input: "02-01 13:29:23.994 8141 8141 I art : at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1118)", output: null },
282+
{ input: "02-01 13:29:23.994 8141 8141 I art : at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2599)", output: null },
283+
{ input: "02-01 13:29:23.994 8141 8141 I art : at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2707)", output: null },
284+
{ input: "02-01 13:29:23.994 8141 8141 I art : at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)", output: null },
285+
{ input: "02-01 13:29:23.994 8141 8141 I art : at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1460)", output: null },
286+
{ input: "02-01 13:29:23.994 8141 8141 I art : at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)", output: null },
287+
{ input: "02-01 13:29:23.994 8141 8141 I art : at void android.os.Looper.loop() (Looper.java:154)", output: null },
288+
{ input: "02-01 13:29:23.994 8141 8141 I art : at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6077)", output: null },
289+
{ 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+
{ 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+
{ 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 },
206292
];
207293

208294
describe("androidLogFilter", () => {

0 commit comments

Comments
 (0)