Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

@cayozin

Android Studio Logcat regex expressions for efficient debugging

Logcat provides several default filter options (Verbose, Info, Debug etc) and a simple pattern match filter, but the regex filter is the most powerful option for customizing logcat output. Here, I provide 3 useful patterns that have been frequently used to search the logcat more efficiently.

1. Basic INCLUDE filter:

(logging|FA)

where logcat will only show lines containing the expressions separated by "|" (case-insensitive).

For example, "logging" may be a unique log identifier for your application, and FA is the output from the Firebase Analytics library

2. INCLUDE exact string filter (case-sensitive)

(?i)\bFA\b

here, we find logs that match FA exactly e.g. FA, FA-SVC from the Firebase Analytics library, and not any line that includes FA, Fa, fa etc

3. EXCLUDE filter by message type/source

Alternatively, if we want to display most of the logs (because we want to observe any unexpected library crashes or device warnings), it is better to EXCLUDE only those messages we can confidently ignore for the current session.

e.g.

^(?:(?!D/|I/|E/|W/|V/|Wifi|audio_hw_extn).)*$\r?\n?

where

  • E/ corresponds to Error messages, I/ corresponds to Info messages, etc..
  • Wifi, audio_hw_extn corresponds to any message containing these common keywords

Examples of message sources that frequent pollute the logcat and may not be useful for debugging include:
- GnssLocationProvider
- Bundle
- WifiService
- audio_hw_extn
- sensors-hal
- FA|FA-SVC (verbose logging from Firebase Analytics, if not disabled in the application code)

One could also copy their un-filtered logcat to an online text analyzer e.g. https://www.online-utility.org/text/analyzer.jsp to find the most common sources of logs.

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
0
Help us understand the problem. What are the problem?