aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/events/Event.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/events/Event.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/events/Event.java73
1 files changed, 60 insertions, 13 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);
}
/**