How do I send logs to my Android developer friends

I recently started to work again with Android devices, and I remember about the way I like to send logs to my Android dev partners when I found something on our app. I think, what we all commonly do is to open our Android Studio or our terminal and start logcat, see the logs we want, select them, copy and paste them in a .txt

Some time ago, someone, I think Oscar Martínez, with whom I worked in Quepasa and The Meet Group, showed me a tool called Pidcat (https://github.com/JakeWharton/pidcat) back then, it was very good tool because it simplified a lot your logs. With a simple:

pidcat com.your.appname

you could have colorful logs and filtered to only show logs for your app.

Sometime after, I got the idea of helping my Android devs by sending them filtered, colorful logs, for them not to have to sift thru my previous plain text, full of other system/apps logs. I realized that we cannot just copy and paste Pidcat logs to a TXT, the colors wouldn’t show. Needed something to port over the colors with the logs. After investigating a little bit, found a tool called aha (https://github.com/theZiz/aha).

What aha does is to transform or translate ANSI color codes to HTML color tags. With this what you can do is start Pidcat, redirect its output to aha, then save that to an HTML file. However, not long time ago I got a new computer, and tried to install Pidcat and I have been having a lot of issues with it. It seems the project doesn’t have a lot of movement lately, had to manually fix something after installation and when trying to use it with my “Application Under Test” (AUT) didn’t work, the output doesn’t show completely, cut off, etc.

So, I searched for what was the parameter directly in logcat to get logcat logs to show up with colors, then what we can do is the same that with Pidcat, but using logcat directly

Steps

  1. Pre-requisites, Android Studio installed (so we have logcat, handy via adb)
  2. Open the terminal and we do brew update then brew install aha
  3. With these we can do the following:

adb shell logcat --pid=$(adb shell pidof -s com.your.appname) -v time -v color | aha --title ’Title Logs' > path/to/the/logsfile.html

where --pid=$(adb shell pidof -s com.tu.aplicacion) specifies the app to get logs from,
-v time tells it to write timestamps
-v color tells it to colorize the logs
the pipe (|) tells it to send the output of that to the next command, aha and > redirect that output aha to the HTML file.

Once we do on the device our test, to finish up and close up the file we can just hit ctrl + C. That’s the file we are going to share.

What do you think? Do you have any other tips or tricks for us to collaborate with our Devs and help out a little bit more? Let me know in the comments section below

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.