1

I'm compiling in debug mode a certain .so in the Android-Native layer which by default outputs to the default logging file.

However, I do not want this data to be saved to the logs in the first place because it will overwhelm the logging file; I plan on streaming it off of the device.

POSSIBLE SOLUTIONS

  1. Modify the .so code to output the debug info to NOT the logging file.
    Definitely the most straightforward way but I'd prefer not to do this since this'll require modification of the .so. I agree this should be trivial modification but I have a requirement to modify the .so as little as possible.
  2. Is there a way to create an alias for a file, pipe all writes to it through my app (like tee) and selectively allow writes to the real file?
  3. Is there a built-in logcat filtering tool that can do this filtering for me with some regexs?
Bob
  • 4,576
  • 7
  • 39
  • 107
  • `adb logcat -v threadtime MySpammyTag:E` ? That would filter out anything tagged with `MySpammyTag` with a severity below `ANDROID_LOG_ERROR` (use `S` if you want to silence that tag completely). – Michael Jun 12 '17 at 15:00

1 Answers1

0

First of all, the first solution is indeed the trivial and the better one - since it remains in the code unlike the logcat filtering that might get deleted. If the requirement is to modify the .so as little as possible, there is no real problem - you modify the code using #ifdef for debug only, so the code changes for debug mode, but the generated .so for release does not change. This will give you a very good control - but in case you have a lot of 'special' debug code, it will make your code a little ugly...

Edit: If you want to write to you own log, you can run logcat using Runtime class, with your own parameters - look here: Using GREP command to filter logcat in Android.

Regarding the logcat filtering - you can use regex in the filtering in Android Studio. You have a 'regex' check box next to the input box. See here for more details: How to exclude certain messages by TAG name using Android adb logcat?

yakobom
  • 2,681
  • 1
  • 25
  • 33
  • This solution doesn't prevent from the data being saved to the logfile; it prevents me from seeing. – Bob Jun 12 '17 at 14:18
  • @Adrian I merely referred to your point, you wrote #1 as a possible solution, you did not say you do not know how to do this one. I'm updating my answer to cover that as well. – yakobom Jun 13 '17 at 03:50