mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 19:04:49 +00:00
Moved disable and enable logging to dedicated class, removed unecessary imports
This commit is contained in:
@@ -1,24 +1,12 @@
|
||||
package org.toop;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.core.LoggerContext;
|
||||
import org.apache.logging.log4j.core.config.Configuration;
|
||||
import org.apache.logging.log4j.core.config.LoggerConfig;
|
||||
import org.toop.eventbus.EventRegistry;
|
||||
import org.toop.eventbus.Events;
|
||||
import org.toop.eventbus.GlobalEventBus;
|
||||
import org.toop.Logging;
|
||||
import org.toop.server.backend.ServerManager;
|
||||
import org.toop.server.frontend.ConnectionManager;
|
||||
import org.toop.server.backend.TcpServer;
|
||||
|
||||
import org.toop.game.*;
|
||||
import org.toop.game.tictactoe.*;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class Main {
|
||||
@@ -26,7 +14,7 @@ public class Main {
|
||||
|
||||
public static void main(String[] args) throws ExecutionException, InterruptedException {
|
||||
initSystems();
|
||||
disableLogs();
|
||||
Logging.disableLogs();
|
||||
|
||||
ConsoleGui console = new ConsoleGui();
|
||||
|
||||
@@ -42,20 +30,4 @@ public class Main {
|
||||
new ConnectionManager();
|
||||
}
|
||||
|
||||
public static void disableLogs() {
|
||||
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||
Configuration config = ctx.getConfiguration();
|
||||
LoggerConfig loggerConfig = config.getLoggerConfig(EventRegistry.class.getName());
|
||||
loggerConfig.setLevel(Level.OFF);
|
||||
ctx.updateLoggers(); // apply changes immediately
|
||||
}
|
||||
|
||||
public static void enableLogs(Level level) {
|
||||
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||
Configuration config = ctx.getConfiguration();
|
||||
LoggerConfig loggerConfig = config.getLoggerConfig(EventRegistry.class.getName());
|
||||
loggerConfig.setLevel(level);
|
||||
ctx.updateLoggers();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user