package com.jenjinstudios.io.concurrency;

import com.jenjinstudios.io.Message;
import com.jenjinstudios.io.MessageWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.List;

/**
 * Writes messages from the outgoing list in the MessageQueue.
 *
 * @author Caleb Brinkman
 */
public class WriteTask implements Runnable
{
    private static final Logger LOGGER = LoggerFactory.getLogger(WriteTask.class);
    private final MessageQueue messageQueue;
    private final MessageWriter messageWriter;

    /**
     * Construct a new WriteTask that will send messages from the given MessageQueue via the given MessageWriter.
     *
     * @param messageQueue The MessageQueue.
     * @param messageWriter The MessageWriter.
     */
    public WriteTask(MessageQueue messageQueue, MessageWriter messageWriter) {
        this.messageQueue = messageQueue;
        this.messageWriter = messageWriter;
    }

    @Override
    public void run() {
        final List<Message> outgoing = messageQueue.getOutgoingAndClear();
        outgoing.forEach(message -> {
            try {
                messageWriter.write(message);
            } catch (IOException e) {
                messageQueue.errorEncountered(e);
                try {
                    messageWriter.close();
                } catch (IOException e1) {
                    LOGGER.warn("Error when closing message writer", e1);
                }
            }
        });
    }
}

@@ -1109,32 +1109,206 @@
           try %7B%0A
+                if (LOGGER.isDebugEnabled()) %7B%0A                    LOGGER.debug(%22Attempting to write message.  (Type: %7B%7D)%22 + message.getClass().getName());%0A                %7D%0A
                 

Add log statement to WriteTask