Search in sources :

Example 1 with DefaultLogCallback

use of io.fabric8.maven.docker.log.DefaultLogCallback in project docker-maven-plugin by fabric8io.

the class DockerAccessWithHcClient method createExecResponseHandler.

private ResponseHandler<Object> createExecResponseHandler(LogOutputSpec outputSpec) throws FileNotFoundException {
    final LogCallback callback = new DefaultLogCallback(outputSpec);
    return new ResponseHandler<Object>() {

        @Override
        public Object handleResponse(HttpResponse response) throws IOException {
            try (InputStream stream = response.getEntity().getContent()) {
                LineNumberReader reader = new LineNumberReader(new InputStreamReader(stream));
                String line;
                try {
                    callback.open();
                    while ((line = reader.readLine()) != null) {
                        callback.log(1, new Timestamp(), line);
                    }
                } catch (LogCallback.DoneException e) {
                // Ok, we stop here ...
                } finally {
                    callback.close();
                }
            }
            return null;
        }
    };
}
Also used : BuildJsonResponseHandler(io.fabric8.maven.docker.access.chunked.BuildJsonResponseHandler) BodyAndStatusResponseHandler(io.fabric8.maven.docker.access.hc.ApacheHttpClientDelegate.BodyAndStatusResponseHandler) ResponseHandler(org.apache.http.client.ResponseHandler) LogCallback(io.fabric8.maven.docker.access.log.LogCallback) DefaultLogCallback(io.fabric8.maven.docker.log.DefaultLogCallback) HttpResponse(org.apache.http.HttpResponse) DefaultLogCallback(io.fabric8.maven.docker.log.DefaultLogCallback)

Example 2 with DefaultLogCallback

use of io.fabric8.maven.docker.log.DefaultLogCallback in project docker-maven-plugin by fabric8io.

the class LogDispatcher method trackContainerLog.

public synchronized void trackContainerLog(String containerId, LogOutputSpec spec) {
    LogGetHandle handle = dockerAccess.getLogAsync(containerId, new DefaultLogCallback(spec));
    logHandles.put(containerId, handle);
}
Also used : LogGetHandle(io.fabric8.maven.docker.access.log.LogGetHandle)

Example 3 with DefaultLogCallback

use of io.fabric8.maven.docker.log.DefaultLogCallback in project docker-maven-plugin by fabric8io.

the class DefaultLogCallbackTest method before.

@Before
public void before() throws IOException {
    file = File.createTempFile("logcallback", ".log");
    file.deleteOnExit();
    spec = new LogOutputSpec.Builder().prefix("callback-test> ").file(file.toString()).build();
    callback = new DefaultLogCallback(spec);
    callback.open();
    ts = new Timestamp("2016-12-21T15:09:00.999666333Z");
}
Also used : Timestamp(io.fabric8.maven.docker.util.Timestamp) Before(org.junit.Before)

Aggregations

BuildJsonResponseHandler (io.fabric8.maven.docker.access.chunked.BuildJsonResponseHandler)1 BodyAndStatusResponseHandler (io.fabric8.maven.docker.access.hc.ApacheHttpClientDelegate.BodyAndStatusResponseHandler)1 LogCallback (io.fabric8.maven.docker.access.log.LogCallback)1 LogGetHandle (io.fabric8.maven.docker.access.log.LogGetHandle)1 DefaultLogCallback (io.fabric8.maven.docker.log.DefaultLogCallback)1 Timestamp (io.fabric8.maven.docker.util.Timestamp)1 HttpResponse (org.apache.http.HttpResponse)1 ResponseHandler (org.apache.http.client.ResponseHandler)1 Before (org.junit.Before)1