am a0970042: Merge "[Rlog57a] include logUnit boundaries in output"
* commit 'a0970042642ef39c22149a896efe785ec1fcaf01': [Rlog57a] include logUnit boundaries in outputmain
commit
e6bbfda9e0
|
@ -114,8 +114,12 @@ import java.util.Map;
|
||||||
debugStringWriter = null;
|
debugStringWriter = null;
|
||||||
debugJsonWriter = null;
|
debugJsonWriter = null;
|
||||||
}
|
}
|
||||||
final int size = mLogStatementList.size();
|
|
||||||
// Write out any logStatement that passes the privacy filter.
|
// Write out any logStatement that passes the privacy filter.
|
||||||
|
final int size = mLogStatementList.size();
|
||||||
|
if (size != 0) {
|
||||||
|
// Note that jsonWriter is only set to a non-null value if the logUnit start text is
|
||||||
|
// output and at least one logStatement is output.
|
||||||
|
JsonWriter jsonWriter = null;
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
final LogStatement logStatement = mLogStatementList.get(i);
|
final LogStatement logStatement = mLogStatementList.get(i);
|
||||||
if (!isIncludingPrivateData && logStatement.mIsPotentiallyPrivate) {
|
if (!isIncludingPrivateData && logStatement.mIsPotentiallyPrivate) {
|
||||||
|
@ -125,8 +129,12 @@ import java.util.Map;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Only retrieve the jsonWriter if we need to. If we don't get this far, then
|
// Only retrieve the jsonWriter if we need to. If we don't get this far, then
|
||||||
// researchLog.getValidJsonWriter() will not open the file for writing.
|
// researchLog.getValidJsonWriterLocked() will not ever be called, and the file
|
||||||
final JsonWriter jsonWriter = researchLog.getValidJsonWriterLocked();
|
// will not have been opened for writing.
|
||||||
|
if (jsonWriter == null) {
|
||||||
|
jsonWriter = researchLog.getValidJsonWriterLocked();
|
||||||
|
outputLogUnitStart(jsonWriter);
|
||||||
|
}
|
||||||
outputLogStatementToLocked(jsonWriter, mLogStatementList.get(i), mValuesList.get(i),
|
outputLogStatementToLocked(jsonWriter, mLogStatementList.get(i), mValuesList.get(i),
|
||||||
mTimeList.get(i));
|
mTimeList.get(i));
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
|
@ -134,6 +142,11 @@ import java.util.Map;
|
||||||
mValuesList.get(i), mTimeList.get(i));
|
mValuesList.get(i), mTimeList.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (jsonWriter != null) {
|
||||||
|
// We must have called logUnitStart earlier, so emit a logUnitStop.
|
||||||
|
outputLogUnitStop(jsonWriter, isIncludingPrivateData);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
try {
|
try {
|
||||||
debugJsonWriter.endArray();
|
debugJsonWriter.endArray();
|
||||||
|
@ -152,6 +165,35 @@ import java.util.Map;
|
||||||
private static final String CURRENT_TIME_KEY = "_ct";
|
private static final String CURRENT_TIME_KEY = "_ct";
|
||||||
private static final String UPTIME_KEY = "_ut";
|
private static final String UPTIME_KEY = "_ut";
|
||||||
private static final String EVENT_TYPE_KEY = "_ty";
|
private static final String EVENT_TYPE_KEY = "_ty";
|
||||||
|
private static final String WORD_KEY = "_wo";
|
||||||
|
private static final String LOG_UNIT_BEGIN_KEY = "logUnitStart";
|
||||||
|
private static final String LOG_UNIT_END_KEY = "logUnitEnd";
|
||||||
|
|
||||||
|
private void outputLogUnitStart(final JsonWriter jsonWriter) {
|
||||||
|
try {
|
||||||
|
jsonWriter.beginObject();
|
||||||
|
jsonWriter.name(CURRENT_TIME_KEY).value(System.currentTimeMillis());
|
||||||
|
jsonWriter.name(WORD_KEY).value(getWord());
|
||||||
|
jsonWriter.name(EVENT_TYPE_KEY).value(LOG_UNIT_BEGIN_KEY);
|
||||||
|
jsonWriter.endObject();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Log.w(TAG, "Error in JsonWriter; cannot write LogUnitStart");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void outputLogUnitStop(final JsonWriter jsonWriter,
|
||||||
|
final boolean isIncludingPrivateData) {
|
||||||
|
try {
|
||||||
|
jsonWriter.beginObject();
|
||||||
|
jsonWriter.name(CURRENT_TIME_KEY).value(System.currentTimeMillis());
|
||||||
|
jsonWriter.name(EVENT_TYPE_KEY).value(LOG_UNIT_END_KEY);
|
||||||
|
jsonWriter.endObject();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Log.w(TAG, "Error in JsonWriter; cannot write LogUnitStop");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the logStatement and its contents out through jsonWriter.
|
* Write the logStatement and its contents out through jsonWriter.
|
||||||
|
|
Loading…
Reference in New Issue