mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-03-13 03:21:24 +07:00
Added more robust logging for item reader and writer bytes read and written
This commit is contained in:
parent
bebd4dc3ff
commit
52a5508167
@ -22,7 +22,7 @@ public class ItemReader {
|
||||
}
|
||||
|
||||
public Item readItem(ByteInput in) {
|
||||
final int itemOffset = in.bytesRead(); // TODO: remove when serialization implemented
|
||||
final int startOffset = in.bytesRead(); // TODO: remove when serialization implemented
|
||||
Item item = readSingleItem(in);
|
||||
if (item.socketsFilled > 0) log.trace("Reading {} sockets...", item.socketsFilled);
|
||||
for (int i = 0; i < item.socketsFilled; i++) {
|
||||
@ -34,8 +34,16 @@ public class ItemReader {
|
||||
Log.remove("socket");
|
||||
}
|
||||
}
|
||||
final int itemSize = in.bytesRead() - itemOffset; // TODO: remove when serialization implemented
|
||||
item.data = in.duplicate(itemOffset, itemSize); // TODO: remove when serialization implemented
|
||||
final int endOffset = in.bytesRead();
|
||||
final int itemSize = endOffset - startOffset; // TODO: remove when serialization implemented
|
||||
item.data = in.duplicate(startOffset, itemSize); // TODO: remove when serialization implemented
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("size: {} (0x{}) (+{} .. +{})",
|
||||
itemSize,
|
||||
Integer.toHexString(itemSize),
|
||||
Integer.toHexString(startOffset),
|
||||
Integer.toHexString(endOffset));
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.riiablo.item;
|
||||
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@ -18,6 +19,7 @@ public class ItemWriter {
|
||||
private static final byte[] SIGNATURE = {0x4A, 0x4D};
|
||||
|
||||
public ByteOutput writeItem(Item item, ByteOutput out) {
|
||||
final int startOffset = out.bytesWritten();
|
||||
writeSingleItem(item, out);
|
||||
if (item.socketsFilled > 0) log.trace("Writing {} sockets...", item.socketsFilled);
|
||||
for (int i = 0; i < item.socketsFilled; i++) {
|
||||
@ -29,6 +31,20 @@ public class ItemWriter {
|
||||
Log.remove("socket");
|
||||
}
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
final int endOffset = out.bytesWritten();
|
||||
final int itemSize = endOffset - startOffset;
|
||||
log.debug("size: {} (0x{}) (+{} .. +{})",
|
||||
itemSize,
|
||||
Integer.toHexString(itemSize),
|
||||
Integer.toHexString(startOffset),
|
||||
Integer.toHexString(endOffset));
|
||||
if (log.isTraceEnabled()) {
|
||||
Log.tracef(log, "bytes: %n%s", ByteBufUtil.prettyHexDump(out.buffer()));
|
||||
} else {
|
||||
log.debug("bytes: {}", ByteBufUtil.hexDump(out.buffer()));
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user