Skip to content

Commit

Permalink
Cut down on useless startup logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Matyrobbrt committed Aug 19, 2024
1 parent ff3eaea commit 58be7bc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/main/java/net/neoforged/camelot/util/LoggingFilter.java
Original file line number Diff line number Diff line change
@@ -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<ILoggingEvent> {
@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;
};
}
}
8 changes: 8 additions & 0 deletions src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,17 @@
%logger{50}/%marker - %msg%n
</pattern>
</encoder>

<!-- Filter out unneeded messages from the console -->
<filter class="net.neoforged.camelot.util.LoggingFilter" />
</appender>
<!--Log levels include ERROR, WARN, INFO, DEBUG, TRACE -->
<root level="INFO">
<appender-ref ref="CONSOLE" />
</root>

<!-- Disable the annoying useless printout -->
<logger name="org.flywaydb.core.internal.license.VersionPrinter" level="OFF" />
<!-- Disable the duplicate logging -->
<logger name="org.flywaydb.core.internal.database.base.BaseDatabaseType" level="OFF" />
</configuration>

0 comments on commit 58be7bc

Please sign in to comment.