aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/events
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/events')
-rw-r--r--src/main/java/com/google/devtools/build/lib/events/Event.java73
-rw-r--r--src/main/java/com/google/devtools/build/lib/events/EventCollector.java6
-rw-r--r--src/main/java/com/google/devtools/build/lib/events/PrintingEventHandler.java14
3 files changed, 79 insertions, 14 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/events/Event.java b/src/main/java/com/google/devtools/build/lib/events/Event.java
index 5bf5b1dd05..8835d17e06 100644
--- a/src/main/java/com/google/devtools/build/lib/events/Event.java
+++ b/src/main/java/com/google/devtools/build/lib/events/Event.java
@@ -31,6 +31,8 @@ public final class Event implements Serializable {
private final EventKind kind;
private final Location location;
private final String message;
+ @Nullable private final String stdout;
+ @Nullable private final String stderr;
/**
* An alternative representation for message.
@@ -46,23 +48,40 @@ public final class Event implements Serializable {
private final int hashCode;
- private Event(EventKind kind, @Nullable Location location, String message, @Nullable String tag) {
+ private Event(
+ EventKind kind,
+ @Nullable Location location,
+ String message,
+ @Nullable String tag,
+ @Nullable String stdout,
+ @Nullable String stderr) {
this.kind = Preconditions.checkNotNull(kind);
this.location = location;
this.message = Preconditions.checkNotNull(message);
this.messageBytes = null;
this.tag = tag;
- this.hashCode = Objects.hash(kind, location, message, tag, Arrays.hashCode(messageBytes));
+ this.stdout = stdout;
+ this.stderr = stderr;
+ this.hashCode =
+ Objects.hash(kind, location, message, tag, Arrays.hashCode(messageBytes), stdout, stderr);
}
private Event(
- EventKind kind, @Nullable Location location, byte[] messageBytes, @Nullable String tag) {
+ EventKind kind,
+ @Nullable Location location,
+ byte[] messageBytes,
+ @Nullable String tag,
+ @Nullable String stdout,
+ @Nullable String stderr) {
this.kind = Preconditions.checkNotNull(kind);
this.location = location;
this.message = null;
this.messageBytes = Preconditions.checkNotNull(messageBytes);
this.tag = tag;
- this.hashCode = Objects.hash(kind, location, message, tag, Arrays.hashCode(messageBytes));
+ this.stdout = stdout;
+ this.stderr = stderr;
+ this.hashCode =
+ Objects.hash(kind, location, message, tag, Arrays.hashCode(messageBytes), stdout, stderr);
}
public Event withTag(String tag) {
@@ -70,9 +89,17 @@ public final class Event implements Serializable {
return this;
}
if (this.message != null) {
- return new Event(this.kind, this.location, this.message, tag);
+ return new Event(this.kind, this.location, this.message, tag, this.stdout, this.stderr);
+ } else {
+ return new Event(this.kind, this.location, this.messageBytes, tag, this.stdout, this.stderr);
+ }
+ }
+
+ public Event withStdoutStderr(String stdout, String stderr) {
+ if (this.message != null) {
+ return new Event(this.kind, this.location, this.message, this.tag, stdout, stderr);
} else {
- return new Event(this.kind, this.location, this.messageBytes, tag);
+ return new Event(this.kind, this.location, this.messageBytes, this.tag, stdout, stderr);
}
}
@@ -97,6 +124,24 @@ public final class Event implements Serializable {
}
/**
+ * Get the stdout bytes associated with this event; typically, the event will report where the
+ * output originated from.
+ */
+ @Nullable
+ public String getStdOut() {
+ return stdout;
+ }
+
+ /**
+ * Get the stdout bytes associated with this event; typically, the event will report where the
+ * output originated from.
+ */
+ @Nullable
+ public String getStdErr() {
+ return stderr;
+ }
+
+ /**
* Returns the location of this event, if any. Returns null iff the event
* wasn't associated with any particular location, for example, a progress
* message.
@@ -133,6 +178,8 @@ public final class Event implements Serializable {
&& Objects.equals(this.location, that.location)
&& Objects.equals(this.tag, that.tag)
&& Objects.equals(this.message, that.message)
+ && Objects.equals(this.stdout, that.stdout)
+ && Objects.equals(this.stderr, that.stderr)
&& Arrays.equals(this.messageBytes, that.messageBytes);
}
@@ -146,7 +193,7 @@ public final class Event implements Serializable {
}
public static Event of(EventKind kind, @Nullable Location location, String message) {
- return new Event(kind, location, message, null);
+ return new Event(kind, location, message, null, null, null);
}
/**
@@ -155,42 +202,42 @@ public final class Event implements Serializable {
* The bytes must be decodable as UTF-8 text.
*/
public static Event of(EventKind kind, @Nullable Location location, byte[] messageBytes) {
- return new Event(kind, location, messageBytes, null);
+ return new Event(kind, location, messageBytes, null, null, null);
}
/**
* Reports an error.
*/
public static Event error(@Nullable Location location, String message){
- return new Event(EventKind.ERROR, location, message, null);
+ return new Event(EventKind.ERROR, location, message, null, null, null);
}
/**
* Reports a warning.
*/
public static Event warn(@Nullable Location location, String message) {
- return new Event(EventKind.WARNING, location, message, null);
+ return new Event(EventKind.WARNING, location, message, null, null, null);
}
/**
* Reports atemporal statements about the build, i.e. they're true for the duration of execution.
*/
public static Event info(@Nullable Location location, String message) {
- return new Event(EventKind.INFO, location, message, null);
+ return new Event(EventKind.INFO, location, message, null, null, null);
}
/**
* Reports a temporal statement about the build.
*/
public static Event progress(@Nullable Location location, String message) {
- return new Event(EventKind.PROGRESS, location, message, null);
+ return new Event(EventKind.PROGRESS, location, message, null, null, null);
}
/**
* Reports a debug message.
*/
public static Event debug(@Nullable Location location, String message) {
- return new Event(EventKind.DEBUG, location, message, null);
+ return new Event(EventKind.DEBUG, location, message, null, null, null);
}
/**
diff --git a/src/main/java/com/google/devtools/build/lib/events/EventCollector.java b/src/main/java/com/google/devtools/build/lib/events/EventCollector.java
index 46bf3adf3f..63c64a6b52 100644
--- a/src/main/java/com/google/devtools/build/lib/events/EventCollector.java
+++ b/src/main/java/com/google/devtools/build/lib/events/EventCollector.java
@@ -66,6 +66,12 @@ public final class EventCollector extends AbstractEventHandler implements Iterab
if (getEventMask().contains(event.getKind())) {
collected.add(event);
}
+ if (event.getStdErr() != null) {
+ handle(Event.of(EventKind.STDERR, null, event.getStdErr()));
+ }
+ if (event.getStdOut() != null) {
+ handle(Event.of(EventKind.STDOUT, null, event.getStdOut()));
+ }
}
/**
diff --git a/src/main/java/com/google/devtools/build/lib/events/PrintingEventHandler.java b/src/main/java/com/google/devtools/build/lib/events/PrintingEventHandler.java
index fc16475694..fc57456d9c 100644
--- a/src/main/java/com/google/devtools/build/lib/events/PrintingEventHandler.java
+++ b/src/main/java/com/google/devtools/build/lib/events/PrintingEventHandler.java
@@ -81,7 +81,8 @@ public class PrintingEventHandler extends AbstractEventHandler
*/
@Override
public void handle(Event event) {
- if (!getEventMask().contains(event.getKind())) {
+ if (!getEventMask().contains(event.getKind())) {
+ handleFollowUpEvents(event);
return;
}
try {
@@ -113,5 +114,16 @@ public class PrintingEventHandler extends AbstractEventHandler
*/
outErr.printErrLn(e.getMessage());
}
+ handleFollowUpEvents(event);
}
+
+ private void handleFollowUpEvents(Event event) {
+ if (event.getStdErr() != null) {
+ handle(Event.of(EventKind.STDERR, null, event.getStdErr()));
+ }
+ if (event.getStdOut() != null) {
+ handle(Event.of(EventKind.STDOUT, null, event.getStdOut()));
+ }
+ }
+
}