Debug system (#1894)

* Add build (compile) script: gradlew jar

* Move server and services log levels to ConfigContainer, ability to enable/disable show packet payload and loop packets

* Add some loop packets to known list
This commit is contained in:
BiosNod
2022-10-29 13:01:28 +00:00
committed by GitHub
parent 55928d9154
commit 43b7d7a383
7 changed files with 54 additions and 12 deletions

View File

@@ -6,12 +6,13 @@ import emu.grasscutter.BuildConfig;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.Grasscutter.ServerRunMode;
import emu.grasscutter.net.packet.PacketOpcodesUtils;
import io.javalin.core.util.JavalinLogger;
import org.slf4j.LoggerFactory;
import java.util.Map;
import java.util.function.Function;
import static emu.grasscutter.config.Configuration.*;
/**
* A parser for start-up arguments.
*/
@@ -80,14 +81,21 @@ public final class StartupArguments {
* @return False to continue execution.
*/
private static boolean enableDebug(String parameter) {
// Get the level by parameter.
var loggerLevel = parameter != null && parameter.equals("all")
? Level.DEBUG : Level.INFO;
if (parameter != null && parameter.equals("all")) {
// Override default debug configs
GAME_INFO.isShowLoopPackets = DEBUG_MODE_INFO.isShowLoopPackets;
GAME_INFO.isShowPacketPayload = DEBUG_MODE_INFO.isShowPacketPayload;
GAME_INFO.logPackets = DEBUG_MODE_INFO.logPackets;
DISPATCH_INFO.logRequests = DEBUG_MODE_INFO.logRequests;
}
// Set the logger to debug.
Grasscutter.getLogger().setLevel(Level.DEBUG);
// Set the main logger to debug.
Grasscutter.getLogger().setLevel(DEBUG_MODE_INFO.serverLoggerLevel);
Grasscutter.getLogger().debug("The logger is now running in debug mode.");
// Log level to other third-party services
Level loggerLevel = DEBUG_MODE_INFO.servicesLoggersLevel;
// Change loggers to debug.
((Logger) LoggerFactory.getLogger("io.javalin"))
.setLevel(loggerLevel);