aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Klaus Aehlig <aehlig@google.com>2017-05-12 09:03:34 -0400
committerGravatar Kristina Chodorow <kchodorow@google.com>2017-05-12 11:14:08 -0400
commitb006a63603df405808d6a05602786c0ab55a44f5 (patch)
tree33813523d8e4e4c69b92eec416a69ac246a5726a
parentfb30345aaf41ca55d3dbb31f99edf414585c4bec (diff)
experimentalUI: show date, if timestamps are enabled
While builds usually finish in a single day, for console logs (especially those collected on a CI system) it is still useful to know the date they where collected on. So, if --show_timestamps is given, show a line with the current date at the beginning of the build to not lose the information due to the shorter time stamps, compare #2989. Change-Id: Ief2ae011cdb4de7ac5d5a9acd4d200913220b2a3 PiperOrigin-RevId: 155859302
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java b/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java
index da14e8064d..3ee911fe01 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java
@@ -87,6 +87,7 @@ public class ExperimentalEventHandler implements EventHandler {
private long minimalUpdateInterval;
private long lastRefreshMillis;
private long mustRefreshAfterMillis;
+ private boolean dateShown;
private int numLinesProgressBar;
private boolean buildComplete;
// Number of open build even protocol transports.
@@ -133,6 +134,7 @@ public class ExperimentalEventHandler implements EventHandler {
this.minimalUpdateInterval = Math.max(this.minimalDelayMillis, MAXIMAL_UPDATE_DELAY_MILLIS);
this.stdoutBuffer = new byte[] {};
this.stderrBuffer = new byte[] {};
+ this.dateShown = false;
// The progress bar has not been updated yet.
ignoreRefreshLimitOnce();
}
@@ -162,6 +164,18 @@ public class ExperimentalEventHandler implements EventHandler {
return didFlush;
}
+ private synchronized void maybeAddDate() {
+ if (!showTimestamp || dateShown) {
+ return;
+ }
+ dateShown = true;
+ handle(
+ Event.info(
+ null,
+ "Current date is "
+ + DateTimeFormat.forPattern("YYYY-MM-dd").print(clock.currentTimeMillis())));
+ }
+
@Override
public synchronized void handle(Event event) {
try {
@@ -174,6 +188,7 @@ public class ExperimentalEventHandler implements EventHandler {
addProgressBar();
terminal.flush();
} else {
+ maybeAddDate();
switch (event.getKind()) {
case STDOUT:
case STDERR:
@@ -288,6 +303,7 @@ public class ExperimentalEventHandler implements EventHandler {
@Subscribe
public void buildStarted(BuildStartingEvent event) {
+ maybeAddDate();
stateTracker.buildStarted(event);
// As a new phase started, inform immediately.
ignoreRefreshLimitOnce();
@@ -296,6 +312,7 @@ public class ExperimentalEventHandler implements EventHandler {
@Subscribe
public void loadingStarted(LoadingPhaseStartedEvent event) {
+ maybeAddDate();
stateTracker.loadingStarted(event);
// As a new phase started, inform immediately.
ignoreRefreshLimitOnce();
@@ -361,6 +378,7 @@ public class ExperimentalEventHandler implements EventHandler {
@Subscribe
public void downloadProgress(FetchProgress event) {
+ maybeAddDate();
stateTracker.downloadProgress(event);
refresh();
}