diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java index 9b2101ac95aba7..7c608c6f8e5657 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java @@ -66,7 +66,6 @@ import com.google.devtools.build.lib.server.FailureDetails; import com.google.devtools.build.lib.server.FailureDetails.FailureDetail; import com.google.devtools.build.lib.util.ExitCode; -import com.google.devtools.build.lib.util.io.FileOutErr; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.longrunning.Operation; @@ -274,7 +273,7 @@ public SpawnResult exec(Spawn spawn, SpawnExecutionContext context) // It's already late at this stage, but we should at least report once. reporter.reportExecutingIfNot(); - maybePrintExecutionMessages(context, result.getMessage(), result.success()); + maybePrintExecutionMessages(spawn, result.getMessage(), result.success()); profileAccounting(result.getExecutionMetadata()); spawnMetricsAccounting(spawnMetrics, result.getExecutionMetadata()); @@ -445,14 +444,16 @@ public boolean handlesCaching() { return true; } - private void maybePrintExecutionMessages( - SpawnExecutionContext context, String message, boolean success) { - FileOutErr outErr = context.getFileOutErr(); + private void maybePrintExecutionMessages(Spawn spawn, String message, boolean success) { boolean printMessage = remoteOptions.remotePrintExecutionMessages.shouldPrintMessages(success) && !message.isEmpty(); if (printMessage) { - outErr.printErr(message + "\n"); + report( + Event.info( + String.format( + "Remote execution message for %s %s: %s", + spawn.getMnemonic(), spawn.getTargetLabel(), message))); } } @@ -533,7 +534,8 @@ private SpawnResult handleError( } } if (e.isExecutionTimeout()) { - maybePrintExecutionMessages(context, e.getResponse().getMessage(), /* success = */ false); + maybePrintExecutionMessages( + action.getSpawn(), e.getResponse().getMessage(), /* success= */ false); return new SpawnResult.Builder() .setRunnerName(getName()) .setStatus(Status.TIMEOUT)