Enable debug mode for plugin loggers if enabled for the primary logger

This commit is contained in:
KingRainbow44 2023-05-20 23:13:01 -04:00
parent b88b3717c3
commit 0cad9a90c0
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE

View File

@ -1,15 +1,17 @@
package emu.grasscutter.plugin;
import ch.qos.logback.classic.Level;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.plugin.api.ServerHelper;
import emu.grasscutter.plugin.api.ServerHook;
import emu.grasscutter.server.game.GameServer;
import emu.grasscutter.utils.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.InputStream;
import java.net.URLClassLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** The base class for all plugins to extend. */
@SuppressWarnings("removal")
@ -39,6 +41,10 @@ public abstract class Plugin {
this.dataFolder = FileUtils.getPluginPath(identifier.name).toFile();
this.logger = LoggerFactory.getLogger(identifier.name);
// Check if the logger should be set in debug mode.
if (Grasscutter.getLogger().isDebugEnabled())
((ch.qos.logback.classic.Logger) logger).setLevel(Level.DEBUG);
if (!this.dataFolder.exists() && !this.dataFolder.mkdirs()) {
Grasscutter.getLogger()
.warn("Failed to create plugin data folder for " + this.identifier.name);