Merge "Add additional structure to output logs to group entries by optional fields."

main
Kurt Partridge 2012-03-21 05:50:01 -07:00 committed by Android (Google) Code Review
commit 221dd3d183
2 changed files with 29 additions and 9 deletions

View File

@ -54,6 +54,7 @@ import com.android.inputmethod.latin.StringUtils;
import com.android.inputmethod.latin.SubtypeUtils;
import com.android.inputmethod.latin.Utils;
import com.android.inputmethod.latin.Utils.UsabilityStudyLogUtils;
import com.android.inputmethod.latin.Utils.UsabilityStudyLogUtils.LogGroup;
import java.util.Locale;
import java.util.WeakHashMap;
@ -701,7 +702,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
break;
}
if (!TextUtils.isEmpty(eventTag)) {
UsabilityStudyLogUtils.getInstance().write(
UsabilityStudyLogUtils.getInstance().write(LogGroup.MOTION_EVENT,
eventTag + eventTime + "," + id + "," + x + "," + y + ","
+ me.getSize(index) + "," + me.getPressure(index));
}
@ -764,9 +765,10 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
}
tracker.onMoveEvent(px, py, eventTime);
if (ENABLE_USABILITY_STUDY_LOG) {
UsabilityStudyLogUtils.getInstance().write("[Move]" + eventTime + ","
+ me.getPointerId(i) + "," + px + "," + py + ","
+ me.getSize(i) + "," + me.getPressure(i));
UsabilityStudyLogUtils.getInstance().write(
LogGroup.MOTION_EVENT,
"[Move]" + eventTime + "," + me.getPointerId(i) + "," + px + "," + py
+ "," + me.getSize(i) + "," + me.getPressure(i));
}
}
} else {

View File

@ -263,8 +263,25 @@ public class Utils {
}
}
/**
* Represents a category of logging events that share the same subfield structure.
*/
public static enum LogGroup {
MOTION_EVENT("m"),
KEY("k"),
CORRECTION("c"),
STATE_CHANGE("s");
private final String mLogString;
private LogGroup(String logString) {
mLogString = logString;
}
}
public static void writeBackSpace(int x, int y) {
UsabilityStudyLogUtils.getInstance().write("<backspace>\t" + x + "\t" + y);
UsabilityStudyLogUtils.getInstance().write(
LogGroup.KEY, "<backspace>\t" + x + "\t" + y);
}
public void writeChar(char c, int x, int y) {
@ -280,11 +297,12 @@ public class Utils {
inputChar = "<space>";
break;
}
UsabilityStudyLogUtils.getInstance().write(inputChar + "\t" + x + "\t" + y);
UsabilityStudyLogUtils.getInstance().write(LogGroup.KEY,
inputChar + "\t" + x + "\t" + y);
LatinImeLogger.onPrintAllUsabilityStudyLogs();
}
public void write(final String log) {
public void write(final LogGroup logGroup, final String log) {
mLoggingHandler.post(new Runnable() {
@Override
public void run() {
@ -292,8 +310,8 @@ public class Utils {
final long currentTime = System.currentTimeMillis();
mDate.setTime(currentTime);
final String printString = String.format("%s\t%d\t%s\n",
mDateFormat.format(mDate), currentTime, log);
final String printString = String.format("%s\t%d\t%s\t%s\n",
mDateFormat.format(mDate), currentTime, logGroup.mLogString, log);
if (LatinImeLogger.sDBG) {
Log.d(USABILITY_TAG, "Write: " + log);
}