Skip to content

Commit

Permalink
Can't use blank log messages!
Browse files Browse the repository at this point in the history
  • Loading branch information
rtyley committed Feb 6, 2012
1 parent 3374c30 commit 24a6d94
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,20 @@

public class Screenshots {

/**
* The paparazzo process filters logcat for this tag
*/
public static final String TAG = "screenshot_request";

public static void poseForScreenshot() {
Log.d("screenshot_request", "");
/* Note that the log message can not be blank, otherwise it won't
* register with logcat.
*/
Log.d(TAG, "{}");

/* Wait for the development machine to take the screenshot (usually takes about
* half a second)
*/
try { sleep(1000L); } catch (InterruptedException e) {}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,20 @@ private void takeScreenshotFor(String logLine) {
}
}

/**
* Parse the logline into key-value pairs. The logline format is comma-separated
* key-value pairs surrounded by curly braces, ie:
*
* {foo=bar,name=ARandomName}
*/
private Map<String, String> keyValueMapFor(String logLine) {
Map<String, String> keyValueMap = new HashMap<String, String>();
for (String keyValuePair : logLine.split(",")) {
int separatorIndex = keyValuePair.indexOf("=");
if (separatorIndex > 0) {
keyValueMap.put(keyValuePair.substring(0, separatorIndex), keyValuePair.substring(separatorIndex));
if (logLine.startsWith("{") && logLine.endsWith("}")) {
for (String keyValuePair : logLine.substring(1, logLine.length()-1).split(",")) {
int separatorIndex = keyValuePair.indexOf("=");
if (separatorIndex > 0) {
keyValueMap.put(keyValuePair.substring(0, separatorIndex), keyValuePair.substring(separatorIndex));
}
}
}
return keyValueMap;
Expand Down

0 comments on commit 24a6d94

Please sign in to comment.