Nativescript-cli: Disable system log in TNS 4 console

Created on 5 Jul 2018  路  14Comments  路  Source: NativeScript/nativescript-cli

Hello,

I'am using NativeScript Vue for developing my app, however, since upgrading to TNS 4, the tns console output log is too much verbose with system logging messages. Is there any way to disable all these logs and print only application level logs ?

Every time I run the app, it's impossible to see my debug log since there are a lot of system logs, for example:

AVAudioSession.mm:323:HandleRouteChange: Posting AVAudioSessionRouteChangeNotification. Reason: 3
0x10293e818 - UIProcess is releasing a foreground assertion because the view is no longer visible
0x10b944210 - ProcessThrottler::updateAssertion() sending PrepareToSuspend IPC
0x1c4a6ab80 - ProcessAssertion::setState(1)
0x10b944000 - WebProcessProxy::didSetAssertionState(Background) taking background assertion for network process
0x10b940138 - ProcessThrottler::updateAssertionNow() updating process assertion state to 1 (foregroundActivities: 0, backgroundActivities: 1)
0x1c4a6a980 - ProcessAssertion::setState(1)
0x10b944210 - ProcessThrottler::updateAssertionNow() updating process assertion state to 0 (foregroundActivities: 0, backgroundActivities: 0)
0x1c4a6ab80 - ProcessAssertion::setState(0)
0x10b944000 - WebProcessProxy::didSetAssertionState(Suspended) release all assertions for network process
0x10b940138 - ProcessThrottler::updateAssertion() sending PrepareToSuspend IPC
0x10b940138 - ProcessThrottler::updateAssertionNow() updating process assertion state to 0 (foregroundActivities: 0, backgroundActivities: 0)
0x1c4a6a980 - ProcessAssertion::setState(0)
0x1c4854640 - WKProcessAssertionBackgroundTaskManager - endBackgroundTask
0x10b944210 - ProcessThrottler::updateAssertionNow() updating process assertion state to 1 (foregroundActivities: 0, backgroundActivities: 1)
0x1c4a6ab80 - ProcessAssertion::setState(1)
0x1c4854640 - WKProcessAssertionBackgroundTaskManager - beginBackgroundTaskWithName
0x10b944000 - WebProcessProxy::didSetAssertionState(Background) taking background assertion for network process
0x10b940138 - ProcessThrottler::updateAssertionNow() updating process assertion state to 1 (foregroundActivities: 0, backgroundActivities: 1)
0x1c4a6a980 - ProcessAssertion::setState(1)
0x10b944000 - WebProcessProxy::didSetAssertionState(Background) taking background assertion for network process
0x10b944000 - WebProcessProxy::didSetAssertionState(Background) taking background assertion for network process
0x10b944000 - WebProcessProxy::didSetAssertionState(Background) taking background assertion for network process
0x10b944000 - WebProcessProxy::didSetAssertionState(Background) taking background assertion for network process
0x10b944000 - WebProcessProxy::didSetAssertionState(Background) taking background assertion for network process
0x10b944000 - WebProcessProxy::didSetAssertionState(Background) taking background assertion for network process
0x10b944210 - ProcessThrottler::updateAssertion() sending PrepareToSuspend IPC
0x10b944000 - WebProcessProxy::didSetAssertionState(Background) taking background assertion for network process
0x10b944000 - WebProcessProxy::didSetAssertionState(Background) taking background assertion for network process
0x10b944000 - WebProcessProxy::didSetAssertionState(Background) taking background assertion for network process
0x10b944000 - WebProcessProxy::didSetAssertionState(Background) taking background assertion for network process
0x10b944000 - WebProcessProxy::didSetAssertionState(Background) taking background assertion for network process
0x10b944000 - WebProcessProxy::didSetAssertionState(Background) taking background assertion for network process
0x10b944000 - WebProcessProxy::didSetAssertionState(Background) taking background assertion for network process
0x10b944000 - WebProcessProxy::didSetAssertionState(Background) taking background assertion for network process
0x10b944000 - WebProcessProxy::didSetAssertionState(Background) taking background assertion for network process

Issue occurs since TNS 4.0

  • Both iOS/Android

To recreate the issue

  • Execute command tns [run|debug] [ios|andorid] for any NativeScript project.

Thank you for any help.

ios device logs

Most helpful comment

The only workaround I have so far is to manually edit ios-log-filter.js by adding additional filtering conditions:

preFilter(data, currentLine) {
        return currentLine.length < 1 ||
            currentLine.indexOf("WebProcessProxy") !== -1 ||
            currentLine.indexOf("ProcessAssertion") !== -1 ||
            currentLine.indexOf("ProcessThrottler") !== -1 ||
            currentLine.indexOf("locationd") !== -1 ||
            currentLine.indexOf("SecTaskCopyDebugDescription") !== -1 ||
            currentLine.indexOf("NativeScript loaded bundle") !== -1 ||
            (currentLine.indexOf("assertion failed:") !== -1 && data.indexOf("libxpc.dylib") !== -1);
}

This is obviously a hack (and still misses a ton of system logs), but at least (for now) I can filter out the noisiest system logs so I can see more of my own.


EDIT:

This works better...

preFilter(data, currentLine) {
        return currentLine.length < 1 || currentLine.indexOf("CONSOLE") === -1 ;
}

All 14 comments

This is a headache for debugging. Any workarounds yet?

@NickIliev This issue is not specific to Nativescript Vue. When running on iOS, the console gets flooded with system logs related to networking, geolocation services, etc.

The only workaround I have so far is to manually edit ios-log-filter.js by adding additional filtering conditions:

preFilter(data, currentLine) {
        return currentLine.length < 1 ||
            currentLine.indexOf("WebProcessProxy") !== -1 ||
            currentLine.indexOf("ProcessAssertion") !== -1 ||
            currentLine.indexOf("ProcessThrottler") !== -1 ||
            currentLine.indexOf("locationd") !== -1 ||
            currentLine.indexOf("SecTaskCopyDebugDescription") !== -1 ||
            currentLine.indexOf("NativeScript loaded bundle") !== -1 ||
            (currentLine.indexOf("assertion failed:") !== -1 && data.indexOf("libxpc.dylib") !== -1);
}

This is obviously a hack (and still misses a ton of system logs), but at least (for now) I can filter out the noisiest system logs so I can see more of my own.


EDIT:

This works better...

preFilter(data, currentLine) {
        return currentLine.length < 1 || currentLine.indexOf("CONSOLE") === -1 ;
}

@speigg thanks for your workaround, it works great 馃憤

Thing that I don't understand is there was a PR which has been created for this problem :
https://github.com/NativeScript/nativescript-cli/pull/3389/files

But while using real iOS device, we still get too many useless logs, but if we use Xcode, then the debugger console is clear and contains only useful log.

So there is certainly a solution to get the Xcode logs, instead of current nativescript iOS logs

I'm having the same issue, @speigg @GrEg00z where is the ios-log-filter.js file located?

easy workaround: tns debug ios --bundle | grep CONSOLE

If you need to see the chrome devtools link:

tns debug ios --bundle | grep 'CONSOLE\|chrome'

Still, this is just a workaround, you will not see any fatal errors from nativescript etc ... so you need to adjust the grep command ...

This seems to be either the same issue or at least related to #3544.

One problem with filtering, e.g. with grep, is that it's effectively impossible to see object dumps (e.g. the output of console.dir(object); in the app code).

Any concerns/objections to have @speigg 's solution as the default for ios-log-filter.js?

This works better...

preFilter(data, currentLine) {
        return currentLine.length < 1 || currentLine.indexOf("CONSOLE") === -1 ;
}

Any concerns/objections to have @speigg 's solution as the default for ios-log-filter.js?

This works better...

preFilter(data, currentLine) {
        return currentLine.length < 1 || currentLine.indexOf("CONSOLE") === -1 ;
}

No sir, you can go 馃憤

@GrEg00z where can this ios-log-filter.js file be found?

@RacknerFrank depending on where your (global) node modules are located it's

$YOUR_NODE_HOME/node_modules/nativescript/lib/services/ios-log-filter.js

@lambourn Wouldn't that strip all console.dir(object); output?

@RacknerFrank : on windows 10, it's located here :

  • C:\Users\your user\AppData\Roaming\npm\node_modules\nativescript\lib\services
  • C:\Users\your user\AppData\Roaming\npm\node_modules\nativescript\lib\commonmobile

As said @kenny-evitt, the right one should be in nativescript\lib\services, but not sure, I edited the both to be sure

FYI I haven鈥檛 looked at this in a long time so I don鈥檛 remember the details, but if I recall correctly I don鈥檛 think my workaround works for multi-line console output. (I could be wrong).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ZMW9 picture ZMW9  路  3Comments

jerbob92 picture jerbob92  路  3Comments

erjdriver picture erjdriver  路  3Comments

DimitarTachev picture DimitarTachev  路  3Comments

bradmartin picture bradmartin  路  3Comments