package com.nirima.jenkins.plugins.docker.utils;

import com.github.dockerjava.api.model.ResponseItem;
import hudson.model.BuildListener;

/**
 * @author Kanstantsin Shautsou
 */
public class LogUtils {
    private LogUtils() {
    }

    public static void printResponseItemToListener(BuildListener listener, ResponseItem item) {
        if (item.getStatus() != null) {
            if (item.getError() != null) {
                listener.error(item.getError());
            }

            final StringBuilder stringBuffer = new StringBuilder();

            if (item.getId() != null) {
                stringBuffer.append(item.getId()).append(": "); // Doesn't exist before "Digest"
            }

            stringBuffer.append(item.getStatus());

            if (item.getProgress() != null) {
                stringBuffer.append(" ").append(item.getProgress());
            }

            listener.getLogger().println(stringBuffer.toString());
        }
    }
}

@@ -130,16 +130,50 @@
 istener;
+%0Aimport hudson.model.TaskListener;
 %0A%0A/**%0A *
@@ -313,21 +313,20 @@
 istener(
-Build
+Task
 Listener

Make logging take superclass so not tied to Builds only.