How do I specify OR in DDMS - android

I know I can use regular expressions in DDMS window but can't figure out how. Suppose, I have filter 1 filtering by log label "A" and filter 2 filtering by log label "B" so what do I print in the ddms edit panel so I have both outputs from "A" and from "B" and nothing else?

You can use regular expressions inside the log panel,let's say you want to filter by tag,you write inside the tag filter:
^com.test.TestClassA$|^com.test.TestClassB$
It accepts simple boolean logic too,so even something along these lines would work:
com.test.TestClassA|com.test.TestClassB
No spaces between OR bars.
You can even do it directly from logcat top window,by appending a prefix for your desired scope:
tag:com.test.TestClassA|com.test.TestClassB
or the regex
tag:^com.test.TestClassA$|^com.test.TestClassB$
hope this is useful for you.

Try with the regular expression:
^TAG_A$|^TAG_B$

Related

How to display two or more logcat filters at the same time in Android Studio?

I have declared two LOG.i such as followings in my code:
Log.i("pen", pen.toString);
Log.i("book", book.toString);
Then I added these two filters to my Logcat window (via Edit Filter Configuration):
Filter1 with 'LOG TAG' set to pen
Filter2 with 'LOG TAG' set to book
I have no problem to see them each individually (by selecting them each in drop-down filter in logcat window).
NOW What I need to know is HOW to display both filters at the same time?
Have you tried using regex? Do as the screenshot below and you should see both tags at the same time
For copy/paste: (pen|book)
Note this accepts any number of tags as long as you separate them with |
Thanks for all responses, they all were really helpful, however I found what I was looking for, if you really do not want to create a new filter just copy and paste something similar (pen|book) to the Search box on the main logcat window and do not forget to tick Regex box next to it.
Via the Edit filter configuration, create or edit a filter with Log Tag(regex) (or check regex depending on the version of android studio) set to
pen|book
I can not take a screenshot now, I'm sorry.
Otherwise using the command line you can do (on linux)
adb logcat | grep -e book -e pen
Have you tried separating both values by coma or semi-colon or |?
LOG TAG: pen, book
or
LOG TAG: pen; book
or
LOG TAg: pen|book

Copy "Text" column content only from logcat view

Does anybody know of a way, or something that could ease the process of manually removing the extra strings, to get only the content of the "Text" column in the logcat view when copying the logcat content?
Seems not possible, but I've drawn an attention to it through android issues portal:
https://code.google.com/p/android/issues/detail?id=77883&thanks=77883&ts=1413891569
Hopefully it will be implemented soon enough, as it woudl be really helpful.
There are two ways to achieve that:
The First Way, if you have multiple lines:
copy your text to Notepad++ or any editor that uses Regex.
press ctrl+f and choose Replace tab.
use a Regex format in order to remove all the unnecessary tags info, for example in the case of System.out messages, the Regex formula will be:
\d*-\d* \d*:\d*:\d*\.\d*: I\/System\.out\(\d*\):
if the messages are like:
03-14 14:44:17.557: I/System.out(18293):
finaly, use this formula in [find what] field and use a white space in the [Replace with] field, and don't forget to choose Regular Expression choice in the (search mode) field.
The second way, if you have a single line of log: as described here:
Right click on the line in Logcat which you wish to copy text from
Click “find similar messages”
In the window that pops up the text is contained in the field “by Log Message:”
This text can now be copied via Ctrl+C

solo.searchText does not identify "$"

I am using solo.searchText function in my robotium testcases. I am passing the text as "$ testdata" for searching. But it is not detecting the text even if the text is there in the screen. Do we need to handle special charecters before using solo.searchText()? Please help me
Use Pattern.quote() as mentioned here to search for special characters that would otherwise be interpreted as regular expressions.
solo.searchText(Pattern.quote(stringWithSpecialCharacters))

What regex can be used to filter out dalvikvm AND dalvikvm-heap messages from the logcat

Using this link I was able to create a filter using the regex (?!dalvikvm\b)\b\w+ to filter out messages with the tag dalvikvm, but I have tried several variations of the regex such as (?!dalvikvm-heap\b)\b\w+, (?!dalvikvm\\-heap\b)\b\w+, (?!dalvikvm[-]heap\b)\b\w+, and many others and I can't seem to get rid of the dalvikvm-heap messages. Ideally I would like to filter them both, but I haven't figured that part out yet either.
Any help would be appreciated.
Use ^(?!dalvikvm) in the tag field instead. That will show only messages whose tag doesn't start with "dalvikvm".
The below is notes about how this works; you can skip them if you're not interested. To start, you have to remember that the question, "Does this string match the regex?" really means, "Is there any position in this string where the regex matches?"
The tricky thing about (?!x) negative assertions is that they match wherever the next part of the string doesn't match x: but that's true of every place in the string "dalvikvm" except the start. The blog post you linked to adds a \b at the end so that the expression matches only at a place that's not just before "dalvikvm" and is a word boundary. But this would still match, because the end of the string is a word boundary, and it doesn't have "dalvikvm" after it. So the blog post adds the \w+ after it, to say that after the word boundary there have to be more word characters.
It works for exactly that case, but it's a bit of an odd way of making a regex, and it's relatively expensive to evaluate. And as you've noticed, you can't adapt it to (?!dalvikvm-heap\b)\b\w+. "-" is a non-word character, so immediately after it, there is a word boundary, followed by word characters, and not followed by "dalvikvm-heap", so the regex matches at that point.
Instead, I use ^, which only matches at the start of the string, along with the negative assertion. Overall, the regex only matches at the start of the string, and only then if the start of the string isn't followed by "dalvikvm". That means it won't match "dalvikvm" or "dalvikvm-heap". It's also cheaper to evaluate, because the regex engine knows it can only possibly match at the start.
Making the regex this way, you can filter out multiple tags by just putting them together. For example, ^(?!dalvikvm)(?!IInputConnectionWrapper) will filter out tags that start with "dalvikvm" or "IInputConnectionWrapper", because the start of the string has to not be followed by the first and not be followed by the second.
BTW, thanks for your link. I didn't realise that you could use the logcat filters that way, so I wouldn't have come up with my answer without it.

Filter tags in LogCat (in Android Eclipse Plug-In)

There is a TextField "Filter" below the LogCat output. However, it seems to filter only the Message-column. Id like to filter Tags also. Because there are my class names.
How can I achieve it?
There's a button that looks like a green + in the upper right of the log cat window, if you mouse over it says "Create Filter" in the popup from that you can filter by log tag. It creates a new tab in log cat with the filter name you specified. Then all of the output of that tag will go to that tab and not the "Log" tab.
In Eclipse, if I would like to exclude those annoying Choreographer messages,I write this filter in the logcat filter TextField : tag:^(?!Choreographer).*$ and it excludes all messages which tag starts with the text Choreographer
If you want multiple exclusions : tag:^(?!Choreographer|dalvikvm-heap|Trace).*$
The Log tag field accepts Java regular expressions, so try this:
^TAG_A$|^TAG_B$
which matches exactly those tags. You can go crazy with complicated regular expressions, if that's your idea of fun.
Old question, but still relevant, and didn't see this answer among the answers here.
To filter by multiple columns in logcat textfield, simply use a space between regular expressions, and the column title in lower case followed by : to assign the regex to that column instead of the default "text:"
for example:
tag:wif text:event
a space '' is used as an AND argument.
a single '|' without space is an OR.
Regarding one of the comments I've seen here - There is no realy need for a wildcard, since it is automatically applied before and after the filter text.
If you don't want wildcard, you can use regular expression syntax to restrict the string.
for example: ^starswith or fullword$
TIP: if you want to match a space character or a tab in your output, just type in: \s at the desired place.
A sample from the ADB manual:
adb logcat ActivityManager:I MyApp:D *:S
The *:S is vital as this would suppress other tags different than the ones specified by us.
Unfortunately, one can't use wildcards in the names, i.e.:
adb logcat ActivityManager:I MyApp*:D *:S
wouldn't work.
When filtering, you must use no whitespace after 'tag:' and all is case sensitive. For example:
tag:MIRKO
and not
TAG: mirko
Run logcat in a shell and pipe it through grep.
There's probably even a way to do execute this from an eclipse window that would capture the output.
this should be the same across all platforms, but I'm specifically doing this on Mac Snow leopard, helios....
with the latest eclipse and android plugin, go to window -> show view -> android -> logcat
then in the upper right corner of the view there are filter buttons : "V" "D" "I" "W" "E" then a + edit and -
click on the + and type in your tag, or pid
enjoy filtered logCat
In LogCat's search textbox, you will see the hint text "Search for messages, Accepts Java regexes, Prefix with pid:, app:, tag: or text: to limit scope."
So just type in tag:YOUR_TAG_NAME

Categories

Resources