Ignoring some logs in Logcat filter – Android Studio – solution

Here is a little help to remove from our logcat some logs we don’t want like: dalvikvm or OpenGL
All what you need is to click in top right corner of logcat, select our package name and click Edit Filter Configuration

2015-04-28_11h04_27

Then in the field called Log Tag regex You need insert this
^((?!(?:dalvikvm|OpenGLRenderer)).)*$ which means you don’t want any log which contains dalvivm or OpenGLRenderer. If You want add another word to ignore list just insert inside of regex

|word

For example:
^((?!(?:dalvikvm|OpenGLRenderer|Word)).)*$

Android source code from grepcode.com + Notepad++ with regex

Did You have problem with copying text from grepcode? Did You have problem with a lot spaces and wrong formatting?
Well it is possible to reformat that text with two commands using regex in notepad.

Let’s say we have this:

175

176

public void [More ...] setButtonDrawable(int resid) {

177

if (resid != 0 && resid == mButtonResource) {

178

return;

179

}

It is possible to convert original source to better format like this:

public void setButtonDrawable(int resid) {
if (resid != 0 && resid == mButtonResource) {
return;
}
mButtonResource = resid;
Drawable d = null;
if (mButtonResource != 0) {
d = getResources().getDrawable(mButtonResource);
}
setButtonDrawable(d);
}

How?

You have to paste Your selected code to Notepad++, then click CTRL+H (for replacing function). Select at the bottom option for regex. And finally make two replacing steps:
1. replace from \d+\s+\r\n to (empty text here)
1. replace from ^[\s+][\r\n$] to (empty text here)

And that’s it!