Fix pidcat on macOS 12.5 Monterey

Fix pidcat on macOS 12.5 Monterey

ยท

3 min read

What is pidcat?

pidcat is a helpful tool that can be used as an alternative to adb logcat. It adds indentation to improve readability, colourizes the output based on the log level, and enables filtering.

See logs for all processes

For example, you can see logs for all apps and processes on your Android:

pidcat

Filter by app or process

You can also filter by a specific app by filtering its package name:

pidcat stream.techygrrrl.periodtrackrrr

To get all packages available on your device you can use adb directly:

adb shell pm list packages -3 -f

Here's example output for pidcat com.dd.doordash:

doordash pidcat.png

You can also check out the Twitch logs with pidcat tv.twitch.android.app:

image.png

These are the logs from the period tracking app Trackrrr I built. Looks like I have to fix a crash that occurs when the user cancels an import ๐Ÿ˜ฌ.

image.png

Filter by log level

You can filter for only warnings or errors by passing a log level flag:

pidcat -l E

Here's some example error-only logs:

image.png

Get Python 2 on macOS

Apple has made it very difficult to install Python 2 on your Mac. The package has been removed from Homebrew. If you do happen to install it to your Mac, you will not be able to add it to /usr/bin as Apple prevents you from writing to that.

After looking at Homebrew, the Python website, and a variety of StackOverflow posts, I learned about pyenv, a Python version manager. This seemed like the best optionโ€”I already use nvm and rbenv for version management for Node and Ruby and have had an overall good developer experience with them.

Install Python 2

Install version 2.7.18 globally:

pyenv install 2.7.18

Expose globally

Expose this globally on your path:

pyenv global 2.7.18

This means that whenever you type python in the z shell or bash, you should get the Python 2.x REPL:

$ python
Python 2.7.18 (default, Sep  6 2022, 16:11:05)
[GCC Apple LLVM 13.1.6 (clang-1316.0.21.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

If everything is working, you can proceed to the next step.

Configure pidcat to use Python 2.x

Next, find your pidcat path. It's probably somewhere around /usr/local/Cellar/pidcat/. Find the pidcat executable. Mine was at /usr/local/Cellar/pidcat/2.1.0/bin/pidcat.

Open this executable in your favourite text editor. You will need administrator permissions to change this.

At the top, replace the existing shebang line (probably #!/usr/bin/python -u) with this:

#!/usr/bin/env python -u

This will tell the script to look for python on your environment. If pyenv and the python global are configured properly, this should now work.

Run pidcat

You should now be able to use pidcat by running that in the command line.

If something doesn't work, let me know in the comments (in case I forgot to mention something).

  • pidcat
  • Theme: If you like my iTerm theme, CMYK colourrrrs is available for iTerm and a variety of text editors and IDE's.

About me

I stream software development on Twitch, including but not limited to Android, macOS, chat bots, Twitch extensions, and full stack web apps. You can find me at twitch.tv/techygrrrl.

ย