package org.craft.atom.io;

import java.util.Arrays;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * An super abstract class for {@link IoHandler}.
 * Can be extended and selectively override required event handler methods only.
 * 
 * @author mindwind
 * @version 1.0, Feb 21, 2013
 */
abstract public class AbstractIoHandler implements IoHandler {
	
	
	private static final Logger LOG = LoggerFactory.getLogger(AbstractIoHandler.class);

	
	@Override
	public void channelOpened(Channel<byte[]> channel) {
		LOG.debug("[CRAFT-ATOM-IO] Opened channel={}", channel);
	}

	@Override
	public void channelClosed(Channel<byte[]> channel) {
		LOG.debug("[CRAFT-ATOM-IO] Closed channel={}", channel); 
	}

	@Override
	public void channelIdle(Channel<byte[]> channel) {
		LOG.debug("[CRAFT-ATOM-IO] Idle channel={}", channel);
	}

	@Override
	public void channelRead(Channel<byte[]> channel, byte[] bytes) {
		LOG.debug("[CRAFT-ATOM-IO] Read channel={}, bytes={}", channel, Arrays.toString(bytes));
	}

	@Override
	public void channelFlush(Channel<byte[]> channel, byte[] bytes) {
		LOG.debug("[CRAFT-ATOM-IO] Flush channel={}, bytes={}", channel, Arrays.toString(bytes));
	}

	@Override
	public void channelWritten(Channel<byte[]> channel, byte[] bytes) {
		LOG.debug("[CRAFT-ATOM-IO] Written channel={}, bytes={}", channel, Arrays.toString(bytes));
	}

	@Override
	public void channelThrown(Channel<byte[]> channel, Throwable cause) {
		LOG.warn("[CRAFT-ATOM-IO] Thrown channel={}", channel, cause);
	}
	
}

@@ -554,16 +554,17 @@
  Opened 
+%7C
 channel=
@@ -557,32 +557,33 @@
 ened %7Cchannel=%7B%7D
+%7C
 %22, channel);%0A%09%7D%0A
@@ -684,16 +684,17 @@
  Closed 
+%7C
 channel=
@@ -687,32 +687,33 @@
 osed %7Cchannel=%7B%7D
+%7C
 %22, channel); %0A%09%7D
@@ -811,16 +811,17 @@
 O%5D Idle 
+%7C
 channel=
@@ -814,32 +814,33 @@
 Idle %7Cchannel=%7B%7D
+%7C
 %22, channel);%0A%09%7D%0A
@@ -951,16 +951,17 @@
 O%5D Read 
+%7C
 channel=
@@ -964,32 +964,33 @@
 nel=%7B%7D, bytes=%7B%7D
+%7C
 %22, channel, Arra
@@ -1127,16 +1127,17 @@
 %5D Flush 
+%7C
 channel=
@@ -1140,32 +1140,33 @@
 nel=%7B%7D, bytes=%7B%7D
+%7C
 %22, channel, Arra
@@ -1307,16 +1307,17 @@
 Written 
+%7C
 channel=
@@ -1328,16 +1328,17 @@
 bytes=%7B%7D
+%7C
 %22, chann
@@ -1487,16 +1487,17 @@
  Thrown 
+%7C
 channel=
@@ -1498,16 +1498,17 @@
 annel=%7B%7D
+%7C
 %22, chann

fix - log format of craft-atom-io