A newbie logcat question here, I am sure this is well known but could not find the answer. Sorry.
I want to use logcat for the users of my app MyApp
to email me crash reports that obviously I don't know where they will appear. I want to print Warning and above only for my app.
I read the the documentation, and understood that, to print logcat only for a package I should do something like:
logcat -d -v time MyApp:W *:S
However that does not work: that is just for tags, not for app names.
I read people suggesting something like
logcat -d -v time *:W | grep MyApp
but that does not work either: the error messages, exactly what I am interested in, do not print MyApp
name in all the lines.
I also tried
logcat -d -v time --pid=$(pidof -s MyApp) *:W
but that does not work either since the app crashed already, so it is not running, and it will send me the log of the still running MyApp
PID.
What I ended up doing was to print only the last 20 minutes of everything with:
long timesinceepoch = System.currentTimeMillis()/1000 - 1200;
Process process = Runtime.getRuntime().exec("logcat -d -v time -t "+timesinceepoch+".0 *:W");
but I still get lots of trash and big files, of course.
So how do I add a MyApp tag to ALL the logcat logs of MyApp
?
EDIT: Actually, in Android Studio the MyApp
appears in the logcat, and there is an option to show logcat for a single app. Isn't Android Studio logcat and adb logcat the same??
This is totally unnecessary since when an app calls logcat
it only logs the calling app logs. See this (thanks @jake-lee !).