diff options
author | Keuin <[email protected]> | 2020-12-29 13:58:30 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2020-12-29 13:58:30 +0800 |
commit | aa90c4c8a2be23e890ce1cac4a5980dce5163c4a (patch) | |
tree | b913a42d5777e963757459ff3126ee142d96f090 | |
parent | b773bf20f143ecb31b3ea53aefd08d266707de5d (diff) |
Improved the disable of mongo driver spamming. Improve compatibility and reduce plugin size.
-rw-r--r-- | build.gradle | 7 | ||||
-rw-r--r-- | gradle.properties | 2 | ||||
-rw-r--r-- | src/main/java/com/keuin/blame/util/DatabaseUtil.java | 16 |
3 files changed, 13 insertions, 12 deletions
diff --git a/build.gradle b/build.gradle index e1e5c68..0a43752 100644 --- a/build.gradle +++ b/build.gradle @@ -14,14 +14,7 @@ dependencies { implementation 'junit:junit:4.12' implementation 'org.mongodb:mongo-java-driver:3.12.7' - implementation 'org.apache.logging.log4j:log4j-api:2.14.0' - implementation 'org.apache.logging.log4j:log4j-core:2.14.0' - implementation 'ch.qos.logback:logback-classic:1.2.3' - include 'org.mongodb:mongo-java-driver:3.12.7' - include 'org.apache.logging.log4j:log4j-api:2.14.0' - include 'org.apache.logging.log4j:log4j-core:2.14.0' - include 'ch.qos.logback:logback-classic:1.2.3' // To change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" diff --git a/gradle.properties b/gradle.properties index f57ba94..14c297a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ minecraft_version=1.16.4 yarn_mappings=1.16.4+build.6 loader_version=0.10.6+build.214 # Mod Properties -mod_version=1.2.2-alpha +mod_version=1.2.4-alpha maven_group=com.keuin.blame archives_base_name=blame-fabric # Dependencies 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. + } } } |