summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorKeuin <[email protected]>2020-12-29 13:56:57 +0800
committerKeuin <[email protected]>2020-12-29 13:56:57 +0800
commitcf2f9b922360e630229e04262c05d8c91da6916d (patch)
treee964fc8a67d2dc861a59d39b00373f56b745e8f5 /src/main/java
parent6b22ae06457ec44ec22ea39582a02dd4168e397b (diff)
Improved the disable of mongo driver spamming. Improve compatibility and reduce plugin size.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/keuin/blame/util/DatabaseUtil.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/main/java/com/keuin/blame/util/DatabaseUtil.java b/src/main/java/com/keuin/blame/util/DatabaseUtil.java
index dc5cca2..d68bc4d 100644
--- a/src/main/java/com/keuin/blame/util/DatabaseUtil.java
+++ b/src/main/java/com/keuin/blame/util/DatabaseUtil.java
@@ -1,7 +1,8 @@
package com.keuin.blame.util;
-import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.LoggerContext;
+//import ch.qos.logback.classic.Level;
+//import ch.qos.logback.classic.LoggerContext;
+
import com.keuin.blame.Blame;
import com.keuin.blame.config.MongoConfig;
import com.keuin.blame.data.enums.codec.ActionTypeCodec;
@@ -12,7 +13,9 @@ import com.mongodb.MongoClientSettings;
import org.bson.codecs.configuration.CodecRegistries;
import org.bson.codecs.configuration.CodecRegistry;
import org.bson.codecs.pojo.PojoCodecProvider;
-import org.slf4j.LoggerFactory;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
import static org.bson.codecs.configuration.CodecRegistries.fromProviders;
@@ -39,6 +42,11 @@ public class DatabaseUtil {
// db.log.createIndex({ timestamp_millis: -1, subject_id: "hashed" })
public static void disableMongoSpamming() {
- ((LoggerContext) LoggerFactory.getILoggerFactory()).getLogger("org.mongodb.driver").setLevel(Level.ERROR);
+// ((LoggerContext) LoggerFactory.getILoggerFactory()).getLogger("org.mongodb.driver").setLevel(Level.ERROR);
+ String[] mongoDrivers = new String[] {"org.mongodb", "org.mongodb.driver", "org.mongodb.driver.cluster", "org.mongodb.driver.connection"};
+ for (String driverName : mongoDrivers) {
+ Logger mongoLogger = Logger.getLogger(driverName);
+ mongoLogger.setLevel(Level.OFF); // Plz be silent, my boy.
+ }
}
}