summaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
authorKeuin <[email protected]>2020-12-25 15:16:51 +0800
committerKeuin <[email protected]>2020-12-25 15:16:51 +0800
commitf11cb5937d6c6adb8ad4079592d26a718716b646 (patch)
tree2cec8453cf0c435dc54e81a48c9ad86e3b309704 /src/main/java/com
parentd9834858eef6de5b912bb4f0a94bd4b09faa3f04 (diff)
fix MongoDriver spamming
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/keuin/blame/Blame.java8
-rw-r--r--src/main/java/com/keuin/blame/util/DatabaseUtil.java5
2 files changed, 13 insertions, 0 deletions
diff --git a/src/main/java/com/keuin/blame/Blame.java b/src/main/java/com/keuin/blame/Blame.java
index 095d634..b09f23d 100644
--- a/src/main/java/com/keuin/blame/Blame.java
+++ b/src/main/java/com/keuin/blame/Blame.java
@@ -23,6 +23,7 @@ import java.io.IOException;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
+import java.util.logging.Level;
import java.util.logging.Logger;
public class Blame implements ModInitializer {
@@ -51,6 +52,11 @@ public class Blame implements ModInitializer {
return true;
}
+ private static void disableMongoSpamming() {
+ Logger mongoLogger = Logger.getLogger("org.mongodb.driver");
+ mongoLogger.setLevel(Level.WARNING);
+ }
+
@Override
public void onInitialize() {
// This code runs as soon as Minecraft is in a mod-load-ready state.
@@ -60,6 +66,8 @@ public class Blame implements ModInitializer {
if (!loadConfig())
return;
+ disableMongoSpamming();
+
// hook disable event
ServerLifecycleEvents.SERVER_STOPPING.register(new ServerLifecycleEvents.ServerStopping() {
@Override
diff --git a/src/main/java/com/keuin/blame/util/DatabaseUtil.java b/src/main/java/com/keuin/blame/util/DatabaseUtil.java
index d01ffdd..45ea98a 100644
--- a/src/main/java/com/keuin/blame/util/DatabaseUtil.java
+++ b/src/main/java/com/keuin/blame/util/DatabaseUtil.java
@@ -29,4 +29,9 @@ public class DatabaseUtil {
.applyConnectionString(new ConnectionString(MONGO_CONFIG.getAddress()))
.codecRegistry(CODEC_REGISTRY)
.build();
+
+ // TODO: Auto create indexes if the collection is empty
+ // db.log.createIndex({ timestamp_millis: -1 })
+ // db.log.createIndex({ timestamp_millis: -1, object_id: "hashed" })
+ // db.log.createIndex({ timestamp_millis: -1, subject_id: "hashed" })
}