summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/blame
diff options
context:
space:
mode:
authorKeuin <[email protected]>2020-12-29 13:58:30 +0800
committerKeuin <[email protected]>2020-12-29 13:58:30 +0800
commitaa90c4c8a2be23e890ce1cac4a5980dce5163c4a (patch)
treeb913a42d5777e963757459ff3126ee142d96f090 /src/main/java/com/keuin/blame
parentb773bf20f143ecb31b3ea53aefd08d266707de5d (diff)
Improved the disable of mongo driver spamming. Improve compatibility and reduce plugin size.
Diffstat (limited to 'src/main/java/com/keuin/blame')
-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.
+ }
}
}