diff options
author | Klaus Aehlig <aehlig@google.com> | 2017-05-12 09:03:34 -0400 |
---|---|---|
committer | Kristina Chodorow <kchodorow@google.com> | 2017-05-12 11:14:08 -0400 |
commit | b006a63603df405808d6a05602786c0ab55a44f5 (patch) | |
tree | 33813523d8e4e4c69b92eec416a69ac246a5726a /src/main/java/com | |
parent | fb30345aaf41ca55d3dbb31f99edf414585c4bec (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
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java | 18 |
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(); } |