spigot/CraftBukkit-Patches/0075-Make-debug-logging-togglable.patch

70 lines
2.7 KiB
Diff
Raw Normal View History

2023-09-22 02:40:00 +10:00
From d0e4fbb7718ab6b9abc310db7f104bff7b6e14a6 Mon Sep 17 00:00:00 2001
2014-08-17 13:01:04 +02:00
From: Minecrell <dev@minecrell.net>
Date: Sun, 17 Aug 2014 12:42:53 +0200
Subject: [PATCH] Make debug logging togglable.
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
2023-09-22 02:40:00 +10:00
index 58fb1b92ec..b86000179d 100644
2014-08-17 13:01:04 +02:00
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
2021-03-16 09:00:00 +11:00
@@ -18,6 +18,9 @@ import net.minecraft.resources.MinecraftKey;
2014-08-17 13:01:04 +02:00
import net.minecraft.server.MinecraftServer;
2021-03-16 09:00:00 +11:00
import net.minecraft.world.entity.ai.attributes.AttributeRanged;
import net.minecraft.world.entity.ai.attributes.GenericAttributes;
2014-08-17 13:01:04 +02:00
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.config.Configuration;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
2019-07-30 20:52:01 +10:00
@@ -353,4 +356,27 @@ public class SpigotConfig
attackDamage = getDouble( "settings.attribute.attackDamage.max", attackDamage );
2021-06-11 15:00:00 +10:00
( (AttributeRanged) GenericAttributes.ATTACK_DAMAGE ).maxValue = attackDamage;
2014-08-17 13:01:04 +02:00
}
+
+ public static boolean debug;
+ private static void debug()
+ {
+ debug = getBoolean( "settings.debug", false );
+
+ if ( debug && !LogManager.getRootLogger().isTraceEnabled() )
+ {
+ // Enable debug logging
+ LoggerContext ctx = (LoggerContext) LogManager.getContext( false );
+ Configuration conf = ctx.getConfiguration();
+ conf.getLoggerConfig( LogManager.ROOT_LOGGER_NAME ).setLevel( org.apache.logging.log4j.Level.ALL );
+ ctx.updateLoggers( conf );
+ }
+
+ if ( LogManager.getRootLogger().isTraceEnabled() )
+ {
+ Bukkit.getLogger().info( "Debug logging is enabled" );
+ } else
+ {
+ Bukkit.getLogger().info( "Debug logging is disabled" );
+ }
+ }
}
diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml
2023-09-22 02:40:00 +10:00
index 40be2a9680..722ca84968 100644
2014-08-17 13:01:04 +02:00
--- a/src/main/resources/log4j2.xml
+++ b/src/main/resources/log4j2.xml
2020-01-22 09:18:13 +11:00
@@ -24,10 +24,10 @@
2014-08-17 13:01:04 +02:00
<filters>
<MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL" />
</filters>
2020-01-22 08:00:00 +11:00
- <AppenderRef ref="SysOut"/>
+ <AppenderRef ref="SysOut" level="info"/>
2014-08-17 13:01:04 +02:00
<AppenderRef ref="File"/>
2020-01-22 08:00:00 +11:00
- <AppenderRef ref="ServerGuiConsole"/>
2020-01-22 09:18:13 +11:00
- <AppenderRef ref="TerminalConsole"/>
2020-01-22 08:00:00 +11:00
+ <AppenderRef ref="ServerGuiConsole" level="info"/>
2020-01-22 09:18:13 +11:00
+ <AppenderRef ref="TerminalConsole" level="info"/>
2014-08-17 13:01:04 +02:00
</Root>
</Loggers>
</Configuration>
--
2023-09-22 02:40:00 +10:00
2.42.0
2014-08-17 13:01:04 +02:00