Skip to content

Commit 054ed10

Browse files
author
Ajay Kannan
committed
ensure last line of logs is output
1 parent 5029f00 commit 054ed10

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/LocalGcdHelper.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.google.gcloud.datastore.testing;
1818

19+
import static com.google.common.base.MoreObjects.firstNonNull;
1920
import static java.nio.charset.StandardCharsets.UTF_8;
2021

2122
import com.google.common.base.Strings;
@@ -259,6 +260,7 @@ public void run() {
259260
// ignore
260261
}
261262
}
263+
processLogLine(previousLine, firstNonNull(nextLine, ""));
262264
writeLog(currentLogLevel, currentLog);
263265
}
264266

@@ -279,15 +281,17 @@ private void processLogLine(String previousLine, String nextLine) {
279281
} else {
280282
collectionMode = true;
281283
}
282-
} else if (collectionMode && currentLog.length() > LOG_LENGTH_LIMIT) {
283-
collectionMode = false;
284284
} else if (collectionMode) {
285-
if (currentLog.length() == 0) {
285+
if (currentLog.length() > LOG_LENGTH_LIMIT) {
286+
collectionMode = false;
287+
} else if (currentLog.length() == 0) {
286288
// strip level out of the line
287-
currentLog.append(
288-
"GCD" + previousLine.split(":", 2)[1] + System.getProperty("line.separator"));
289+
currentLog.append("GCD");
290+
currentLog.append(previousLine.split(":", 2)[1]);
291+
currentLog.append(System.getProperty("line.separator"));
289292
} else {
290-
currentLog.append(previousLine + System.getProperty("line.separator"));
293+
currentLog.append(previousLine);
294+
currentLog.append(System.getProperty("line.separator"));
291295
}
292296
}
293297
}

0 commit comments

Comments
 (0)