14
14
import org .geysermc .mcprotocollib .network .packet .PacketRegistry ;
15
15
import org .slf4j .Logger ;
16
16
import org .slf4j .LoggerFactory ;
17
+ import org .slf4j .Marker ;
18
+ import org .slf4j .MarkerFactory ;
17
19
18
20
import java .util .List ;
19
21
20
22
public class TcpPacketCodec extends MessageToMessageCodec <ByteBuf , Packet > {
23
+ private static final Marker marker = MarkerFactory .getMarker ("packet_logging" );
21
24
private static final Logger log = LoggerFactory .getLogger (TcpPacketCodec .class );
22
25
23
26
private final Session session ;
@@ -32,7 +35,7 @@ public TcpPacketCodec(Session session, boolean client) {
32
35
@ Override
33
36
public void encode (ChannelHandlerContext ctx , Packet packet , List <Object > out ) {
34
37
if (log .isTraceEnabled ()) {
35
- log .trace ("Encoding packet: {}" , packet .getClass ().getSimpleName ());
38
+ log .trace (marker , "Encoding packet: {}" , packet .getClass ().getSimpleName ());
36
39
}
37
40
38
41
PacketProtocol packetProtocol = this .session .getPacketProtocol ();
@@ -49,10 +52,10 @@ public void encode(ChannelHandlerContext ctx, Packet packet, List<Object> out) {
49
52
out .add (buf );
50
53
51
54
if (log .isDebugEnabled ()) {
52
- log .debug ("Encoded packet {} ({})" , packet .getClass ().getSimpleName (), packetId );
55
+ log .debug (marker , "Encoded packet {} ({})" , packet .getClass ().getSimpleName (), packetId );
53
56
}
54
57
} catch (Throwable t ) {
55
- log .debug ("Error encoding packet" , t );
58
+ log .debug (marker , "Error encoding packet" , t );
56
59
57
60
PacketErrorEvent e = new PacketErrorEvent (this .session , t );
58
61
this .session .callEvent (e );
@@ -82,7 +85,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf buf, List<Object> out)
82
85
return ;
83
86
}
84
87
85
- log .trace ("Decoding packet with id: {}" , id );
88
+ log .trace (marker , "Decoding packet with id: {}" , id );
86
89
87
90
packet = this .client ? packetRegistry .createClientboundPacket (id , buf , codecHelper ) : packetRegistry .createServerboundPacket (id , buf , codecHelper );
88
91
@@ -93,10 +96,10 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf buf, List<Object> out)
93
96
out .add (packet );
94
97
95
98
if (log .isDebugEnabled ()) {
96
- log .debug ("Decoded packet {} ({})" , packet .getClass ().getSimpleName (), id );
99
+ log .debug (marker , "Decoded packet {} ({})" , packet .getClass ().getSimpleName (), id );
97
100
}
98
101
} catch (Throwable t ) {
99
- log .debug ("Error decoding packet" , t );
102
+ log .debug (marker , "Error decoding packet" , t );
100
103
101
104
// Advance buffer to end to make sure remaining data in this packet is skipped.
102
105
buf .readerIndex (buf .readerIndex () + buf .readableBytes ());
0 commit comments