mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-09 20:02:53 +08:00
Enable debug mode for plugin loggers if enabled for the primary logger
This commit is contained in:
parent
b88b3717c3
commit
0cad9a90c0
@ -1,15 +1,17 @@
|
|||||||
package emu.grasscutter.plugin;
|
package emu.grasscutter.plugin;
|
||||||
|
|
||||||
|
import ch.qos.logback.classic.Level;
|
||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.Grasscutter;
|
||||||
import emu.grasscutter.plugin.api.ServerHelper;
|
import emu.grasscutter.plugin.api.ServerHelper;
|
||||||
import emu.grasscutter.plugin.api.ServerHook;
|
import emu.grasscutter.plugin.api.ServerHook;
|
||||||
import emu.grasscutter.server.game.GameServer;
|
import emu.grasscutter.server.game.GameServer;
|
||||||
import emu.grasscutter.utils.FileUtils;
|
import emu.grasscutter.utils.FileUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/** The base class for all plugins to extend. */
|
/** The base class for all plugins to extend. */
|
||||||
@SuppressWarnings("removal")
|
@SuppressWarnings("removal")
|
||||||
@ -39,6 +41,10 @@ public abstract class Plugin {
|
|||||||
this.dataFolder = FileUtils.getPluginPath(identifier.name).toFile();
|
this.dataFolder = FileUtils.getPluginPath(identifier.name).toFile();
|
||||||
this.logger = LoggerFactory.getLogger(identifier.name);
|
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()) {
|
if (!this.dataFolder.exists() && !this.dataFolder.mkdirs()) {
|
||||||
Grasscutter.getLogger()
|
Grasscutter.getLogger()
|
||||||
.warn("Failed to create plugin data folder for " + this.identifier.name);
|
.warn("Failed to create plugin data folder for " + this.identifier.name);
|
||||||
|
Loading…
Reference in New Issue
Block a user