mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-13 05:44:36 +01:00
Merge pull request #6 from Arikatsu/development
Add config option to disable logging for looping packets
This commit is contained in:
@@ -130,6 +130,7 @@ public class Config {
|
||||
public boolean commands = true;
|
||||
public boolean connections = true;
|
||||
public boolean packets = false;
|
||||
public boolean filterLoopingPackets = false;
|
||||
}
|
||||
|
||||
@Getter
|
||||
|
||||
@@ -127,6 +127,10 @@ public class GameSession {
|
||||
|
||||
// Log packet
|
||||
if (LunarCore.getConfig().getLogOptions().packets) {
|
||||
if (LunarCore.getConfig().getLogOptions().filterLoopingPackets && CmdIdUtils.LOOP_PACKETS.contains(opcode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
logPacket("RECV", opcode, data);
|
||||
}
|
||||
|
||||
@@ -152,6 +156,10 @@ public class GameSession {
|
||||
|
||||
// Log
|
||||
if (LunarCore.getConfig().getLogOptions().packets) {
|
||||
if (LunarCore.getConfig().getLogOptions().filterLoopingPackets && CmdIdUtils.LOOP_PACKETS.contains(packet.getOpcode())) {
|
||||
return;
|
||||
}
|
||||
|
||||
logPacket("SEND", packet.getOpcode(), packet.getData());
|
||||
}
|
||||
}
|
||||
@@ -167,6 +175,10 @@ public class GameSession {
|
||||
|
||||
// Log
|
||||
if (LunarCore.getConfig().getLogOptions().packets) {
|
||||
if (LunarCore.getConfig().getLogOptions().filterLoopingPackets && CmdIdUtils.LOOP_PACKETS.contains(cmdId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
logPacket("SEND", cmdId, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -14,6 +15,13 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public class CmdIdUtils {
|
||||
public static final Set<Integer> LOOP_PACKETS = Set.of(
|
||||
CmdId.PlayerHeartBeatCsReq,
|
||||
CmdId.PlayerHeartBeatScRsp,
|
||||
CmdId.SceneEntityMoveCsReq,
|
||||
CmdId.SceneEntityMoveScRsp
|
||||
);
|
||||
|
||||
private static Int2ObjectMap<String> opcodeMap;
|
||||
|
||||
static {
|
||||
|
||||
Reference in New Issue
Block a user