Yahya Uddin
Yahya Uddin

Reputation: 28861

Titanium: View logs using Logcat on Android

Sometimes when running Titanium for Android, I get disconnected, or have to install it in a different way (e.g. by copying the APK manually), and thus I lose access to my logs.

As far as I'm aware, the logs are generated using Logcat.

Originally I thought you could just do this:

adb -d logcat com.packagename.blah *:S

But that doesn't return any output, as none of the logs use that tag for some reason.

I noticed that a lot of the tags infact used the TiAPI tag, so I tried this:

adb -d logcat TiAPI:I *:S

However this only shows some of the logs.

It doesn't show certain error logs such as:

[ERROR] TiHTTPClient:   at com.android.okhttp.Connection.connect(Connection.java:1413)

For that I would also have to add the tag TiHTTPClient like this:

adb -d logcat TiAPI:I TiHTTPClient:I *:S

But of course it's clear I am missing a lot of other logs my application generates (e.g. native errors, errors from other libraries).

So my question is, how can I view the logs of my Titanium application using LogCat, like we do when we run ti build -p android -T device?

Thanks!

Upvotes: 1

Views: 206

Answers (1)

miga
miga

Reputation: 4055

I use adb logcat | grep -i tiapi or Android Monitor with some custom filters which is getting longer with every testphone: https://gist.github.com/m1ga/b82916dbc38d5255941d

The main problem is that the internal log parser uses regex to separate the logs between ti and non ti-logs. There is still room to improvements since some of the normal logs are difficult to filter out. See this ticket: https://jira.appcelerator.org/browse/TIMOB-24311 for some more information about the topic and the place the filtering takes place. The current solution is not perfect but way better than it was before.

Edit:

I've started a new ticket/PR to improve the log quality for Android: https://jira.appcelerator.org/browse/AC-5621

Upvotes: 2

Related Questions