13
0
geforkt von Mirrors/Paper
Paper/CraftBukkit-Patches/0043-Add-Log-Filtering.patch

81 Zeilen
2.5 KiB
Diff

2013-12-01 04:40:53 +01:00
From b2abcc850b4c50b043f8ef3548ea3c82e839050a Mon Sep 17 00:00:00 2001
2013-06-22 08:40:34 +02:00
From: md_5 <md_5@live.com.au>
Date: Sat, 22 Jun 2013 16:40:11 +1000
Subject: [PATCH] Add Log Filtering
diff --git a/src/main/java/org/spigotmc/LogFilter.java b/src/main/java/org/spigotmc/LogFilter.java
new file mode 100644
index 0000000..aa7e9ab
2013-06-22 08:40:34 +02:00
--- /dev/null
+++ b/src/main/java/org/spigotmc/LogFilter.java
@@ -0,0 +1,24 @@
2013-06-22 08:40:34 +02:00
+package org.spigotmc;
+
+import java.util.logging.Filter;
+import java.util.logging.LogRecord;
+import java.util.regex.Pattern;
+
+public class LogFilter implements Filter
+{
+
+ public boolean isLoggable(LogRecord record)
+ {
+ if ( record.getMessage() != null )
2013-06-22 08:40:34 +02:00
+ {
+ for ( Pattern pattern : SpigotConfig.logFilters )
2013-06-22 08:40:34 +02:00
+ {
+ if ( pattern.matcher( record.getMessage() ).matches() )
+ {
+ return false;
+ }
2013-06-22 08:40:34 +02:00
+ }
+ }
+ return true;
+ }
+}
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
2013-12-01 04:40:53 +01:00
index a3ddb99..e65978b 100644
2013-06-22 08:40:34 +02:00
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
2013-12-01 04:40:53 +01:00
@@ -10,6 +10,8 @@ import java.util.HashMap;
2013-06-22 08:40:34 +02:00
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
import net.minecraft.server.MinecraftServer;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
2013-12-01 04:40:53 +01:00
@@ -167,4 +169,27 @@ public class SpigotConfig
outdatedClientMessage = transform( getString( "messages.outdated-client", "Outdated client!" ) );
outdatedServerMessage = transform( getString( "messages.outdated-server", "Outdated server!" ) );
2013-06-22 08:40:34 +02:00
}
+
+ public static List<Pattern> logFilters;
+ private static void filters()
+ {
+ List<String> def = Arrays.asList( new String[]
+ {
+ "^(.*)(/login)(.*)$"
+ } );
+ logFilters = new ArrayList<Pattern>();
+
+ for ( String regex : (List<String>) getList( "settings.log-filters", def ) )
+ {
+ try
+ {
+ logFilters.add( Pattern.compile( regex ) );
+ } catch ( PatternSyntaxException ex )
+ {
+ Bukkit.getLogger().log( Level.WARNING, "Supplied filter " + regex + " is invalid, ignoring!", ex );
+ }
+ }
+
+ Bukkit.getLogger().setFilter( new LogFilter() );
+ }
}
--
2013-12-01 04:40:53 +01:00
1.8.3.2
2013-06-22 08:40:34 +02:00