Skip to content

Commit 9456ff3

Browse files
committed
Print time and timezone info with message
1 parent 9593f4c commit 9456ff3

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/main/java/cd/go/contrib/elasticagents/docker/PluginRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public void appendToConsoleLog(JobIdentifier jobIdentifier, String text) throws
107107
GoApiResponse response = accessor.submit(request);
108108

109109
if (response.responseCode() != 200) {
110-
LOG.error("Failed to append console log for " + jobIdentifier.represent() + " with text: " + text);
110+
LOG.error("Failed to append to console log for " + jobIdentifier.represent() + " with text: " + text);
111111
}
112112
}
113113
}

src/main/java/cd/go/contrib/elasticagents/docker/executors/CreateAgentRequestExecutor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import cd.go.contrib.elasticagents.docker.requests.CreateAgentRequest;
2121
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse;
2222
import com.thoughtworks.go.plugin.api.response.GoPluginApiResponse;
23+
import org.joda.time.DateTime;
2324
import org.joda.time.LocalDate;
2425
import org.joda.time.LocalTime;
2526
import org.joda.time.format.DateTimeFormat;
@@ -47,7 +48,7 @@ public GoPluginApiResponse execute() throws Exception {
4748
pluginRequest.appendToConsoleLog(request.jobIdentifier(), message);
4849
};
4950

50-
consoleLogAppender.accept(String.format("Received request to create a container of %s", request.dockerImage()));
51+
consoleLogAppender.accept(String.format("Received request to create a container of %s at %s", request.dockerImage(), new DateTime().toString("yyyy-MM-dd HH:mm:ss ZZ")));
5152

5253
try {
5354
agentInstances.create(request, pluginRequest, consoleLogAppender);

src/test/java/cd/go/contrib/elasticagents/docker/executors/CreateAgentRequestExecutorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void shouldAskDockerContainersToCreateAnAgent() throws Exception {
3939
new CreateAgentRequestExecutor(request, agentInstances, pluginRequest).execute();
4040

4141
verify(agentInstances).create(eq(request), eq(pluginRequest), any(ConsoleLogAppender.class));
42-
verify(pluginRequest).appendToConsoleLog(eq(jobIdentifier), contains("Received request to create a container of image1"));
42+
verify(pluginRequest).appendToConsoleLog(eq(jobIdentifier), contains("Received request to create a container of image1 at "));
4343
}
4444

4545
@Test
@@ -60,7 +60,7 @@ public void shouldLogErrorMessageToConsoleIfAgentCreateFails() throws Exception
6060
// expected
6161
}
6262

63-
verify(pluginRequest).appendToConsoleLog(eq(jobIdentifier), contains("Received request to create a container of image1"));
63+
verify(pluginRequest).appendToConsoleLog(eq(jobIdentifier), contains("Received request to create a container of image1 at "));
6464
verify(pluginRequest).appendToConsoleLog(eq(jobIdentifier), contains("Failed while creating container: Ouch"));
6565
}
6666
}

0 commit comments

Comments
 (0)