PaperSpigot-Parent/CraftBukkit-Patches/0152-Make-debug-logging-togglable.patch
Zach Brown 28414e7e28 Update from upstream SpigotMC
6669d6ecd2b
b2740df50bb
bf71dc61149
fba27a2ea80
92ee7e7f8ec
b28f0d3de23
4beb4ac3918
0ddb6f3dde8
afe301fe892
b8f6402bbbe
2014-12-07 13:26:30 -06:00

68 lines
2.4 KiB
Diff

From 870475a482fbfbd4ca771d3be85630cff5427d59 Mon Sep 17 00:00:00 2001
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
index d3abf1f..a8140a5 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -18,6 +18,9 @@ import gnu.trove.map.hash.TObjectIntHashMap;
import net.minecraft.server.AttributeRanged;
import net.minecraft.server.GenericAttributes;
import net.minecraft.server.MinecraftServer;
+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;
@@ -372,4 +375,27 @@ public class SpigotConfig
URL.setURLStreamHandlerFactory(new CachedStreamHandlerFactory());
}
}
+
+ 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
index 08d68aa..f37d1c2 100644
--- a/src/main/resources/log4j2.xml
+++ b/src/main/resources/log4j2.xml
@@ -18,9 +18,9 @@
<filters>
<MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL" />
</filters>
- <AppenderRef ref="WINDOWS_COMPAT"/>
+ <AppenderRef ref="WINDOWS_COMPAT" level="info"/>
<AppenderRef ref="File"/>
- <AppenderRef ref="TerminalConsole"/>
+ <AppenderRef ref="TerminalConsole" level="info"/>
</Root>
</Loggers>
</Configuration>
--
2.1.0