Fix potential errors when plugins log with a null message

This commit is contained in:
md_5 2013-06-26 16:59:37 +10:00
parent 26ed947128
commit a87b0db033

View File

@ -1,4 +1,4 @@
From 12842ce0abe79fc49a1c054dbd3cd04a4959d0c1 Mon Sep 17 00:00:00 2001
From 819926c72091eb14d928f7832e53293d0d27e0b2 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sat, 22 Jun 2013 16:40:11 +1000
Subject: [PATCH] Add Log Filtering
@ -6,10 +6,10 @@ 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..fd26480
index 0000000..aa7e9ab
--- /dev/null
+++ b/src/main/java/org/spigotmc/LogFilter.java
@@ -0,0 +1,21 @@
@@ -0,0 +1,24 @@
+package org.spigotmc;
+
+import java.util.logging.Filter;
@ -21,18 +21,21 @@ index 0000000..fd26480
+
+ public boolean isLoggable(LogRecord record)
+ {
+ for ( Pattern pattern : SpigotConfig.logFilters )
+ if ( record.getMessage() != null )
+ {
+ if ( pattern.matcher( record.getMessage() ).matches() )
+ for ( Pattern pattern : SpigotConfig.logFilters )
+ {
+ return false;
+ if ( pattern.matcher( record.getMessage() ).matches() )
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+}
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index 0d53a5b..cc3b9d8 100644
index 2998109..6528321 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -13,6 +13,8 @@ import java.util.HashMap;