use of com.github.dockerjava.api.command.LogContainerCmd in project camel by apache.
the class AsyncDockerProducer method executeLogContainerRequest.
/**
* Produce a log container request
*
* @param client
* @param message
* @return
*/
private LogContainerCmd executeLogContainerRequest(DockerClient client, Message message) {
LOGGER.debug("Executing Docker Log Container Request");
String containerId = DockerHelper.getProperty(DockerConstants.DOCKER_CONTAINER_ID, configuration, message, String.class);
ObjectHelper.notNull(containerId, "Container ID must be specified");
LogContainerCmd logContainerCmd = client.logContainerCmd(containerId);
Boolean followStream = DockerHelper.getProperty(DockerConstants.DOCKER_FOLLOW_STREAM, configuration, message, Boolean.class);
if (followStream != null) {
logContainerCmd.withFollowStream(followStream);
}
Boolean stdErr = DockerHelper.getProperty(DockerConstants.DOCKER_STD_ERR, configuration, message, Boolean.class);
if (stdErr != null) {
logContainerCmd.withStdErr(stdErr);
}
Boolean stdOut = DockerHelper.getProperty(DockerConstants.DOCKER_STD_OUT, configuration, message, Boolean.class);
if (stdOut != null) {
logContainerCmd.withStdOut(stdOut);
}
Integer tail = DockerHelper.getProperty(DockerConstants.DOCKER_TAIL, configuration, message, Integer.class);
if (tail != null) {
logContainerCmd.withTail(tail);
}
Boolean tailAll = DockerHelper.getProperty(DockerConstants.DOCKER_TAIL_ALL, configuration, message, Boolean.class);
if (tailAll != null && tailAll) {
logContainerCmd.withTailAll();
}
Boolean timestamps = DockerHelper.getProperty(DockerConstants.DOCKER_TIMESTAMPS, configuration, message, Boolean.class);
if (timestamps != null) {
logContainerCmd.withTimestamps(timestamps);
}
return logContainerCmd;
}
use of com.github.dockerjava.api.command.LogContainerCmd in project testcontainers-java by testcontainers.
the class LogUtils method followOutput.
/**
* {@inheritDoc}
*/
public void followOutput(DockerClient dockerClient, String containerId, Consumer<OutputFrame> consumer, OutputFrame.OutputType... types) {
final LogContainerCmd cmd = dockerClient.logContainerCmd(containerId).withFollowStream(true).withSince(0);
final FrameConsumerResultCallback callback = new FrameConsumerResultCallback();
for (OutputFrame.OutputType type : types) {
callback.addConsumer(type, consumer);
if (type == STDOUT)
cmd.withStdOut(true);
if (type == STDERR)
cmd.withStdErr(true);
}
cmd.exec(callback);
}
Aggregations