aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google
diff options
context:
space:
mode:
authorGravatar Klaus Aehlig <aehlig@google.com>2017-05-05 12:25:04 +0200
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2017-05-05 15:27:46 +0200
commit598c90d0a24140ef81042efd3fd4aac9d48ec5ed (patch)
treec966e526d266195e525fb4dd04919b3128f45aef /src/main/java/com/google
parent146f46f70075a072c7de2004c2fa4421b68dcc7b (diff)
experimental_ui: improve --show_timestamp handling
Move the position of the timestamp to the beginning of the line to have a more readable log. Also, show the timestamp for progress as well. While there, reduce timestamp to second precision, to reduce noise. Change-Id: Ibfa6caca2e0d207f54e3660bccbf894bba3c5ae3 PiperOrigin-RevId: 155181731
Diffstat (limited to 'src/main/java/com/google')
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java20
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/ExperimentalStateTracker.java11
2 files changed, 20 insertions, 11 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 fc5eca4344..da14e8064d 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
@@ -71,7 +71,7 @@ public class ExperimentalEventHandler implements EventHandler {
static final long LONG_REFRESH_MILLIS = 20000L;
private static final DateTimeFormatter TIMESTAMP_FORMAT =
- DateTimeFormat.forPattern("(HH:mm:ss.SSS) ");
+ DateTimeFormat.forPattern("(HH:mm:ss) ");
private final boolean cursorControl;
private final Clock clock;
@@ -225,13 +225,13 @@ public class ExperimentalEventHandler implements EventHandler {
if (incompleteLine) {
crlf();
}
+ if (showTimestamp) {
+ terminal.writeString(TIMESTAMP_FORMAT.print(clock.currentTimeMillis()));
+ }
setEventKindColor(event.getKind());
terminal.writeString(event.getKind() + ": ");
terminal.resetTerminal();
incompleteLine = true;
- if (showTimestamp) {
- terminal.writeString(TIMESTAMP_FORMAT.print(clock.currentTimeMillis()));
- }
if (event.getLocation() != null) {
terminal.writeString(event.getLocation() + ": ");
}
@@ -328,11 +328,7 @@ public class ExperimentalEventHandler implements EventHandler {
// The final progress bar will flow into the scroll-back buffer, to if treat
// it as an event and add a timestamp, if events are supposed to have a timestmap.
synchronized (this) {
- if (showTimestamp) {
- stateTracker.buildComplete(event, TIMESTAMP_FORMAT.print(clock.currentTimeMillis()));
- } else {
- stateTracker.buildComplete(event);
- }
+ stateTracker.buildComplete(event);
ignoreRefreshLimitOnce();
refresh();
@@ -637,7 +633,11 @@ public class ExperimentalEventHandler implements EventHandler {
if (cursorControl) {
terminalWriter = new LineWrappingAnsiTerminalWriter(terminalWriter, terminalWidth - 1);
}
- stateTracker.writeProgressBar(terminalWriter, /* shortVersion=*/ !cursorControl);
+ String timestamp = null;
+ if (showTimestamp) {
+ timestamp = TIMESTAMP_FORMAT.print(clock.currentTimeMillis());
+ }
+ stateTracker.writeProgressBar(terminalWriter, /* shortVersion=*/ !cursorControl, timestamp);
terminalWriter.newline();
numLinesProgressBar = countingTerminalWriter.getWrittenLines();
if (progressInTermTitle) {
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalStateTracker.java b/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalStateTracker.java
index e81ce32e61..b11b5cad01 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalStateTracker.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalStateTracker.java
@@ -681,10 +681,14 @@ class ExperimentalStateTracker {
}
}
- synchronized void writeProgressBar(AnsiTerminalWriter rawTerminalWriter, boolean shortVersion)
+ synchronized void writeProgressBar(
+ AnsiTerminalWriter rawTerminalWriter, boolean shortVersion, String timestamp)
throws IOException {
PositionAwareAnsiTerminalWriter terminalWriter =
new PositionAwareAnsiTerminalWriter(rawTerminalWriter);
+ if (timestamp != null) {
+ terminalWriter.append(timestamp);
+ }
if (status != null) {
if (ok) {
terminalWriter.okStatus();
@@ -771,6 +775,11 @@ class ExperimentalStateTracker {
}
}
+ void writeProgressBar(AnsiTerminalWriter terminalWriter, boolean shortVersion)
+ throws IOException {
+ writeProgressBar(terminalWriter, shortVersion, null);
+ }
+
void writeProgressBar(AnsiTerminalWriter terminalWriter) throws IOException {
writeProgressBar(terminalWriter, false);
}