From cf2f9b922360e630229e04262c05d8c91da6916d Mon Sep 17 00:00:00 2001 From: Keuin Date: Tue, 29 Dec 2020 13:56:57 +0800 Subject: Improved the disable of mongo driver spamming. Improve compatibility and reduce plugin size. --- build.gradle | 7 ------- gradle.properties | 2 +- 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 3ab29ae..fd85cb8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ minecraft_version=1.15.2 yarn_mappings=1.15.2+build.17 loader_version=0.10.8 # 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. + } } } -- cgit v1.2.3