From 58be7bc66f8dc608fd846bd074b493274e49d422 Mon Sep 17 00:00:00 2001 From: Matyrobbrt Date: Mon, 19 Aug 2024 23:30:00 +0300 Subject: [PATCH] Cut down on useless startup logging --- .../neoforged/camelot/util/LoggingFilter.java | 26 +++++++++++++++++++ src/main/resources/logback.xml | 8 ++++++ 2 files changed, 34 insertions(+) create mode 100644 src/main/java/net/neoforged/camelot/util/LoggingFilter.java diff --git a/src/main/java/net/neoforged/camelot/util/LoggingFilter.java b/src/main/java/net/neoforged/camelot/util/LoggingFilter.java new file mode 100644 index 0000000..a719b9f --- /dev/null +++ b/src/main/java/net/neoforged/camelot/util/LoggingFilter.java @@ -0,0 +1,26 @@ +package net.neoforged.camelot.util; + +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.filter.Filter; +import ch.qos.logback.core.spi.FilterReply; + +/** + * A Logback filter that filters out unneeded messages. + */ +public class LoggingFilter extends Filter { + @Override + public FilterReply decide(ILoggingEvent event) { + return test(event) ? FilterReply.NEUTRAL : FilterReply.DENY; + } + + private boolean test(ILoggingEvent event) { + return switch (event.getLoggerName()) { + case "org.flywaydb.core.internal.command.DbMigrate" -> !event.getMessage().endsWith("No migration necessary."); + case "org.flywaydb.core.internal.command.DbValidate" -> !event.getMessage().startsWith("Successfully validated"); + + case "io.javalin.Javalin" -> !event.getMessage().equals("Your JDK supports Loom. Javalin will prefer Virtual Threads by default. Disable with `ConcurrencyUtil.useLoom = false`.") + && !event.getMessage().startsWith("Static file handler added:"); + default -> true; + }; + } +} diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 4d51cca..5bca77c 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -31,9 +31,17 @@ %logger{50}/%marker - %msg%n + + + + + + + +