Skip to content

Commit

Permalink
Check on logger cast
Browse files Browse the repository at this point in the history
  • Loading branch information
xdnw committed Sep 5, 2024
1 parent 078021f commit 17d3729
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions src/main/java/link/locutus/discord/Logg.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.async.AsyncLoggerContextSelector;
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.LoggerConfig;
import org.apache.logging.log4j.core.config.builder.api.*;
import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
import org.apache.logging.log4j.spi.LoggerContext;

public class Logg {
private static final Logger LOGGER;
Expand Down Expand Up @@ -43,12 +43,13 @@ public static void setInfoLogging() {
System.setProperty("log4j2.enable.threadlocals", "true"); // Enable garbage-free logging
System.setProperty("log4j2.contextSelector", "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector");

LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
loggerConfig.setLevel(Level.INFO);

ctx.updateLoggers();
LoggerContext ctx = LogManager.getContext(false);
if (ctx instanceof org.apache.logging.log4j.core.LoggerContext logCtx) {
Configuration config = logCtx.getConfiguration();
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
loggerConfig.setLevel(Level.INFO);
logCtx.updateLoggers();
}
// ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
// root.setLevel(ch.qos.logback.classic.Level.INFO);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public boolean isOffensive() {
return this == MDOAP || this == ODOAP;
}

public static TreatyType[] values = values();
public static final TreatyType[] values = values();

public static TreatyType parse(String arg) {
return TreatyType.valueOf(arg.toUpperCase());
Expand Down

0 comments on commit 17d3729

Please sign in to comment.