diff --git a/Mage.Client/config/log4j.properties b/Mage.Client/config/log4j.properties index 932d8c7106..aab212f321 100644 --- a/Mage.Client/config/log4j.properties +++ b/Mage.Client/config/log4j.properties @@ -4,11 +4,11 @@ log4j.rootLogger=info, console, logfile #console log log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout -log4j.appender.console.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n +log4j.appender.console.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n log4j.appender.console.Threshold=info #file log log4j.appender.logfile=org.apache.log4j.FileAppender log4j.appender.logfile.File=mageserver.log log4j.appender.logfile.layout=org.apache.log4j.PatternLayout -log4j.appender.logfile.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n \ No newline at end of file +log4j.appender.logfile.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n \ No newline at end of file diff --git a/Mage.Client/release/config/log4j.properties b/Mage.Client/release/config/log4j.properties index 932d8c7106..aab212f321 100644 --- a/Mage.Client/release/config/log4j.properties +++ b/Mage.Client/release/config/log4j.properties @@ -4,11 +4,11 @@ log4j.rootLogger=info, console, logfile #console log log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout -log4j.appender.console.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n +log4j.appender.console.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n log4j.appender.console.Threshold=info #file log log4j.appender.logfile=org.apache.log4j.FileAppender log4j.appender.logfile.File=mageserver.log log4j.appender.logfile.layout=org.apache.log4j.PatternLayout -log4j.appender.logfile.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n \ No newline at end of file +log4j.appender.logfile.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n \ No newline at end of file diff --git a/Mage.Client/src/main/resources/log4j.properties b/Mage.Client/src/main/resources/log4j.properties index b881e305ad..af6182a5d1 100644 --- a/Mage.Client/src/main/resources/log4j.properties +++ b/Mage.Client/src/main/resources/log4j.properties @@ -1,3 +1,4 @@ +#This configuration file is used for the client started from the IDE #default levels log4j.rootLogger=info, console, logfile # Suppress SQL info messages @@ -9,15 +10,16 @@ log4j.logger.com.j256.ormlite=warn #log4j.logger.mage.client.remote.CallbackClientImpl=debug #log4j.logger.mage.client.remote.CallbackClientImpl=debug #log4j.logger.mage.client.game.FeedbackPanel=debug +#log4j.logger.mage.client.game.FeedbackPanel=warn #console log log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout -log4j.appender.console.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n +log4j.appender.console.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n log4j.appender.console.Threshold=info #file log log4j.appender.logfile=org.apache.log4j.FileAppender log4j.appender.logfile.File=mageclient.log log4j.appender.logfile.layout=org.apache.log4j.PatternLayout -log4j.appender.logfile.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n \ No newline at end of file +log4j.appender.logfile.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n \ No newline at end of file diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer7.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer7.java index 33f9ff60aa..e2322c96be 100644 --- a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer7.java +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer7.java @@ -95,7 +95,7 @@ public class ComputerPlayer7 extends ComputerPlayer6 { public boolean priority(Game game) { if (lastLoggedTurn != game.getTurnNum()) { lastLoggedTurn = game.getTurnNum(); - logger.info(new StringBuilder("============================== ").append("Turn: ").append(game.getTurnNum()).append(" [").append(game.getPlayer(game.getActivePlayerId()).getName()).append("] ====================================================").toString()); + logger.info(new StringBuilder("======================= ").append("Turn: ").append(game.getTurnNum()).append(" [").append(game.getPlayer(game.getActivePlayerId()).getName()).append("] =========================================").toString()); } logState(game); logger.debug("Priority -- Step: " + (game.getTurn().getStepType() + " ").substring(0,25) + " ActivePlayer-" + game.getPlayer(game.getActivePlayerId()).getName() + " PriorityPlayer-" + name); diff --git a/Mage.Server/config/log4j.properties b/Mage.Server/config/log4j.properties index 0417c1344d..513f439d84 100644 --- a/Mage.Server/config/log4j.properties +++ b/Mage.Server/config/log4j.properties @@ -1,15 +1,16 @@ #default levels log4j.rootLogger=debug, console, logfile log4j.logger.com.j256.ormlite=warn +log4j.logger.mage.player.ai=warn #log4j.logger.mage.player.ai.ComputerPlayer6=debug #console log log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout -log4j.appender.console.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n +log4j.appender.console.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M%n log4j.appender.console.Threshold=info #file log log4j.appender.logfile=org.apache.log4j.FileAppender log4j.appender.logfile.File=mageserver.log log4j.appender.logfile.layout=org.apache.log4j.PatternLayout -log4j.appender.logfile.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n \ No newline at end of file +log4j.appender.logfile.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M%n \ No newline at end of file diff --git a/Mage.Server/release/config/log4j.properties b/Mage.Server/release/config/log4j.properties index 8a5569910f..f4a0daec5a 100644 --- a/Mage.Server/release/config/log4j.properties +++ b/Mage.Server/release/config/log4j.properties @@ -1,14 +1,15 @@ #default levels log4j.rootLogger=info, console, logfile log4j.logger.com.j256.ormlite=warn +log4j.logger.mage.player.ai=warn #console log log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout -log4j.appender.console.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n +log4j.appender.console.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M%n log4j.appender.console.Threshold=info #file log log4j.appender.logfile=org.apache.log4j.FileAppender log4j.appender.logfile.File=mageserver.log log4j.appender.logfile.layout=org.apache.log4j.PatternLayout -log4j.appender.logfile.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n \ No newline at end of file +log4j.appender.logfile.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M%n \ No newline at end of file diff --git a/Mage.Server/src/main/java/mage/server/ChatManager.java b/Mage.Server/src/main/java/mage/server/ChatManager.java index 0ee667a2d2..e985a80fee 100644 --- a/Mage.Server/src/main/java/mage/server/ChatManager.java +++ b/Mage.Server/src/main/java/mage/server/ChatManager.java @@ -65,7 +65,7 @@ public class ChatManager { if (chatSessions.containsKey(chatId)) { chatSessions.get(chatId).join(userId); } else { - logger.debug("ChatManager:joinChat - chatId does not exist - chatId: " + chatId +" userId: " + userId); + logger.warn("User could not join chatId: " + chatId +" userId: " + userId); } } @@ -80,7 +80,7 @@ public class ChatManager { if (chatId != null && chatSessions.containsKey(chatId)) { chatSessions.remove(chatId); } else { - logger.debug("ChatManager:destroy chat - chatId does not exist - chatId: " + chatId); + logger.warn("Chat to destroy does not exist - chatId: " + chatId); } } @@ -171,11 +171,9 @@ public class ChatManager { } public void removeUser(UUID userId, DisconnectReason reason) { - Logger.getLogger(ChatManager.class).debug("ChatManager: Remove user start - chatSessions: " + chatSessions.size()); for (ChatSession chat: chatSessions.values()) { chat.kill(userId, reason); } - Logger.getLogger(ChatManager.class).debug("ChatManager: Remove user end"); } public ArrayList getChatSessions() { diff --git a/Mage.Server/src/main/java/mage/server/ChatSession.java b/Mage.Server/src/main/java/mage/server/ChatSession.java index 3c30490e8a..617c2b5b93 100644 --- a/Mage.Server/src/main/java/mage/server/ChatSession.java +++ b/Mage.Server/src/main/java/mage/server/ChatSession.java @@ -71,8 +71,7 @@ public class ChatSession { if (userId != null && clients.containsKey(userId)) { String userName = clients.get(userId); clients.remove(userId); - logger.debug("ChatSession.kill chatSession: " + chatId + " userId: " + userId + " reason: " + (reason == null?"null":reason.toString()) - + " clients.size " + clients.size()); + logger.debug(userName + (reason == null?"null":"(" + reason.toString() +")") + " removed from chatId " + chatId) ; String message = null; switch (reason) { case Disconnected: @@ -82,15 +81,14 @@ public class ChatSession { message = " has lost connection"; break; default: - logger.debug(userName + " left chat " + chatId + " with reason: " + (reason == null ?"null":reason.toString())); + message = reason == null ? " left (unknown reason) ": " left (" + reason.toString() +")"; } if (message != null) { broadcast(null, new StringBuilder(userName).append(message).toString(), MessageColor.BLUE, true, MessageType.STATUS); - logger.debug(userName + " left chat with reason: " + message + " " + chatId); } } } catch(Exception ex) { - logger.fatal("ChatSession.kill exception: " + ex.toString()); + logger.fatal("exception: " + ex.toString()); } } @@ -139,7 +137,7 @@ public class ChatSession { user.fireCallback(new ClientCallback("chatMessage", chatId, new ChatMessage(username, msg, time, color, messageType, soundToPlay))); } else { - logger.debug("ChatSession.broadcast user not found - killed from chat session - userId: " + userId +" chatId: " +chatId); + logger.debug("user not found - killed from chat session - userId: " + userId +" chatId: " +chatId); kill(userId, DisconnectReason.CleaningUp); } } diff --git a/Mage.Server/src/main/java/mage/server/MageServerImpl.java b/Mage.Server/src/main/java/mage/server/MageServerImpl.java index b5ae1fbe5c..70035a0191 100644 --- a/Mage.Server/src/main/java/mage/server/MageServerImpl.java +++ b/Mage.Server/src/main/java/mage/server/MageServerImpl.java @@ -93,7 +93,6 @@ public class MageServerImpl implements MageServer { LogServiceImpl.instance.log(LogKeys.KEY_WRONG_VERSION, userName, version.toString(), Main.getVersion().toString(), sessionId); throw new MageVersionException(version, Main.getVersion()); } - logger.debug(new StringBuilder("RegisterClient - userName: ").append(userName).append(" sessionId = ").append(sessionId)); return SessionManager.getInstance().registerUser(sessionId, userName); } catch (MageException ex) { if (ex instanceof MageVersionException) { @@ -137,7 +136,12 @@ public class MageServerImpl implements MageServer { public TableView execute() throws MageException { UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId(); TableView table = GamesRoomManager.getInstance().getRoom(roomId).createTable(userId, options); - logger.debug("Table " + table.getTableId() + " created"); + if (logger.isDebugEnabled()) { + User user = UserManager.getInstance().getUser(userId); + if (user != null) { + logger.debug(user.getName() + " created tableId: " + table.getTableId()); + } + } LogServiceImpl.instance.log(LogKeys.KEY_TABLE_CREATED, sessionId, userId.toString(), table.getTableId().toString()); return table; } @@ -198,8 +202,12 @@ public class MageServerImpl implements MageServer { @Override public Boolean execute() throws MageException { UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId(); + logger.debug(name + " joins tableId: " + tableId); + if (userId == null) { + logger.fatal("Got no userId from sessionId" + sessionId + " tableId" + tableId); + return false; + } boolean ret = GamesRoomManager.getInstance().getRoom(roomId).joinTable(userId, tableId, name, playerType, skill, deckList); - logger.debug("Session " + sessionId + " joined table " + tableId); return ret; } }); @@ -211,8 +219,17 @@ public class MageServerImpl implements MageServer { @Override public Boolean execute() throws MageException { UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId(); + if (logger.isDebugEnabled()) { + User user = UserManager.getInstance().getUser(userId); + if (user != null) { + logger.debug("join tourn. tableId: " + tableId + " " + user.getName()); + } + } + if (userId == null) { + logger.fatal("Got no userId from sessionId" + sessionId + " tableId" + tableId); + return false; + } boolean ret = GamesRoomManager.getInstance().getRoom(roomId).joinTournamentTable(userId, tableId, name, playerType, skill); - logger.debug("Session " + sessionId + " joined table " + tableId); return ret; } }); @@ -1004,9 +1021,6 @@ public class MageServerImpl implements MageServer { protected void execute(final String actionName, final String sessionId, final Action action) throws MageException { if (SessionManager.getInstance().isValidSession(sessionId)) { try { - if (actionName.equals("joinChat")) { - logger.debug("MageServerImpl.execute sessionId: " + sessionId + " action: " + actionName); - } callExecutor.execute( new Runnable() { @Override diff --git a/Mage.Server/src/main/java/mage/server/Session.java b/Mage.Server/src/main/java/mage/server/Session.java index ef5206a002..0cdc740ea0 100644 --- a/Mage.Server/src/main/java/mage/server/Session.java +++ b/Mage.Server/src/main/java/mage/server/Session.java @@ -217,7 +217,6 @@ public class Session { } public void kill(DisconnectReason reason) { - logger.debug("session removed for user " + userId + " - reason: " + reason.toString()); UserManager.getInstance().removeUser(userId, reason); } diff --git a/Mage.Server/src/main/java/mage/server/SessionManager.java b/Mage.Server/src/main/java/mage/server/SessionManager.java index 982f0a1073..03a519fee2 100644 --- a/Mage.Server/src/main/java/mage/server/SessionManager.java +++ b/Mage.Server/src/main/java/mage/server/SessionManager.java @@ -74,15 +74,18 @@ public class SessionManager { if (session != null) { String returnMessage = session.registerUser(userName); if (returnMessage == null) { - LogServiceImpl.instance.log(LogKeys.KEY_USER_CONNECTED, userName, session.getHost(), sessionId); - logger.info(new StringBuilder("User: ").append(userName) - .append(" userId: ").append(session.getUserId()) - .append(" connected from: ").append(session.getHost()) - .append(" sessionId: ").append(sessionId)); - return true; + LogServiceImpl.instance.log(LogKeys.KEY_USER_CONNECTED, userName, session.getHost(), sessionId); + + logger.info(userName + " joined server"); + logger.debug("- userId: " + session.getUserId()); + logger.debug("- sessionId: " + sessionId); + logger.debug("- host: " + session.getHost()); + return true; } else { - logger.info(new StringBuilder("User not registered - ").append(returnMessage)); + logger.debug(userName + " not registered: " + returnMessage); } + } else { + logger.error(userName + " tried to join with no sessionId"); } return false; } diff --git a/Mage.Server/src/main/java/mage/server/TableController.java b/Mage.Server/src/main/java/mage/server/TableController.java index f0186b6ae6..f3e755fa42 100644 --- a/Mage.Server/src/main/java/mage/server/TableController.java +++ b/Mage.Server/src/main/java/mage/server/TableController.java @@ -159,7 +159,7 @@ public class TableController { } User user = UserManager.getInstance().getUser(userId); if (user == null) { - logger.fatal(new StringBuilder("couldn't get user ").append(name).append(" for join tornament userId = ").append(userId).toString()); + logger.fatal(new StringBuilder("couldn't get user ").append(name).append(" for join tournament userId = ").append(userId).toString()); return false; } if (userPlayerMap.containsKey(userId) && playerType.equals("Human")){ @@ -174,7 +174,7 @@ public class TableController { } tournament.addPlayer(player, seat.getPlayerType()); table.joinTable(player, seat); - logger.debug("player joined " + player.getId()); + logger.trace("player " + player.getName() + " joined tableId: " + table.getId()); //only inform human players and add them to sessionPlayerMap if (seat.getPlayer().isHuman()) { user.addTable(player.getId(), table); @@ -243,14 +243,13 @@ public class TableController { } match.addPlayer(player, deck); table.joinTable(player, seat); - logger.debug("player joined " + player.getId() + " " + player.getName()); + logger.trace(player.getName() + " joined tableId: " + table.getId()); //only inform human players and add them to sessionPlayerMap if (seat.getPlayer().isHuman()) { user.addTable(player.getId(), table); user.joinedTable(table.getRoomId(), table.getId(), false); userPlayerMap.put(userId, player.getId()); } - return true; } @@ -364,7 +363,7 @@ public class TableController { player = PlayerFactory.getInstance().createPlayer(playerType, name, options.getRange(), skill); } if (player != null) { - logger.debug("Player created " + player.getId()); + logger.trace("Player " + player.getName() + " created id: " + player.getId()); } return player; } @@ -466,14 +465,12 @@ public class TableController { public synchronized void startMatch() { if (table.getState() == TableState.STARTING) { try { - String tableInfo; if (table.isTournamentSubTable()) { - tableInfo = "Tournament tournamentId: " + table.getTournament().getId() + " - sub"; + logger.info("Tourn. match started id:" + match.getId() + " tournId: " + table.getTournament().getId()); } else { User user = UserManager.getInstance().getUser(userId); - tableInfo = "User (table controller) " + user.getName(); + logger.info("MATCH started [" + match.getName() + "] " + match.getId() + "(" + user.getName() +")"); } - logger.info(new StringBuilder(tableInfo).append(" match started match Id: ").append(match.getId())); match.startMatch(); startGame(null); } catch (GameException ex) { @@ -501,8 +498,6 @@ public class TableController { user.removeConstructing(match.getPlayer(entry.getValue()).getPlayer().getId()); GameManager.getInstance().joinGame(match.getGame().getId(), user.getId()); } - - logger.info(new StringBuilder("User ").append(user.getName()).append(" game started - gameId ").append(match.getGame().getId()).append(" matchId ").append(match.getId()).append(" userId: ").append(user.getId())); user.gameStarted(match.getGame().getId(), entry.getValue()); if (creator == null) { creator = user.getName(); @@ -514,7 +509,7 @@ public class TableController { } } else { - logger.warn("Unable to find player " + entry.getKey()); + logger.error("Unable to find player " + entry.getKey()); match.getPlayer(entry.getValue()).setQuit(true); } } @@ -531,6 +526,10 @@ public class TableController { ServerMessagesUtil.getInstance().incGamesStarted(); // log about game started + logger.info("GAME started [" + match.getName() +"] "+ creator + " - " + opponent.toString()); + logger.debug("- matchId: " + match.getId() + " [" + match.getName() + "]"); + logger.debug("- gameId: " + match.getGame().getId()); + logger.debug("- chatId: " + GameManager.getInstance().getChatId(match.getGame().getId())); LogServiceImpl.instance.log(LogKeys.KEY_GAME_STARTED, String.valueOf(userPlayerMap.size()), creator, opponent.toString()); } catch (Exception ex) { diff --git a/Mage.Server/src/main/java/mage/server/TableManager.java b/Mage.Server/src/main/java/mage/server/TableManager.java index 0f2139badb..2b5293ab80 100644 --- a/Mage.Server/src/main/java/mage/server/TableManager.java +++ b/Mage.Server/src/main/java/mage/server/TableManager.java @@ -28,6 +28,8 @@ package mage.server; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Date; @@ -63,7 +65,8 @@ public class TableManager { private static final TableManager INSTANCE = new TableManager(); private static final Logger logger = Logger.getLogger(TableManager.class); - + private static final DateFormat formatter = new SimpleDateFormat("hh:mm:ss"); + private final ConcurrentHashMap controllers = new ConcurrentHashMap<>(); private final ConcurrentHashMap tables = new ConcurrentHashMap<>(); @@ -341,7 +344,6 @@ public class TableManager { public void removeTable(UUID tableId) { if (tables.containsKey(tableId)) { Table table = tables.get(tableId); - ChatManager.getInstance().destroyChatSession(controllers.get(tableId).getChatId()); controllers.remove(tableId); tables.remove(tableId); // If table is not finished, the table has to be removed completly (if finished it will be removed in GamesRoomImpl.Update()) @@ -354,23 +356,27 @@ public class TableManager { } } - private void checkExpired() { - logger.debug("--- Table expire checking -----------------------------------------------------------------------"); + public void debugServerState() { + logger.debug("--- Server state ----------------------------------------------"); Collection users = UserManager.getInstance().getUsers(); - logger.debug("------- Users: " + users.size() + " ------------------------"); + logger.debug("--------User: " + users.size() + " [userId | since | name -----------------------"); for (User user :users) { - logger.debug(user.getName() + " SessionId: " + user.getSessionId() + " ConnectionTime: " + user.getConnectionTime()); + logger.debug(user.getId() + " | " + formatter.format(user.getConnectionTime()) + " | " + user.getName() +" (" +user.getUserState().toString() +")"); } ArrayList chatSessions = ChatManager.getInstance().getChatSessions(); - logger.debug("------- ChatSessions: " + chatSessions.size() + " ------------------------"); + logger.debug("------- ChatSessions: " + chatSessions.size() + " ----------------------------------"); for (ChatSession chatSession: chatSessions) { - logger.debug(chatSession.getChatId() + " Clients: " + chatSession.getClients().values().toString()); + logger.debug(chatSession.getChatId() + " " + chatSession.getClients().values().toString()); } - logger.debug("------- Tables: " + tables.size() + " ------------------------"); + logger.debug("------- Tables: " + tables.size() + " --------------------------------------------"); for (Table table: tables.values()) { - logger.debug(table.getId() + " Name: [" + table.getName()+ "] StartTime: " + table.getStartTime()); - } - + logger.debug(table.getId() + " [" + table.getName()+ "] " + formatter.format(table.getStartTime()) +" (" + table.getState().toString() + ")"); + } + logger.debug("--- Server state END ------------------------------------------"); + } + + private void checkExpired() { + debugServerState(); Date now = new Date(); List toRemove = new ArrayList<>(); for (Table table : tables.values()) { @@ -398,5 +404,6 @@ public class TableManager { logger.error(e); } } + } } diff --git a/Mage.Server/src/main/java/mage/server/User.java b/Mage.Server/src/main/java/mage/server/User.java index e6c6a6ee86..c0fc51806c 100644 --- a/Mage.Server/src/main/java/mage/server/User.java +++ b/Mage.Server/src/main/java/mage/server/User.java @@ -120,14 +120,14 @@ public class User { this.sessionId = sessionId; if (sessionId.isEmpty()) { userState = UserState.Disconnected; - logger.debug(new StringBuilder("User ").append(userName).append(" disconnected - userId = ").append(userId.toString()).toString()); + logger.debug("Disconnected User " + userName + " id: " + userId); } else if (userState == UserState.Created) { userState = UserState.Connected; - logger.debug(new StringBuilder("User ").append(userName).append(" created - userId = ").append(userId.toString()).toString()); + logger.debug("Created user " + userName + " id: " + userId); } else { userState = UserState.Reconnected; reconnect(); - logger.info(new StringBuilder("User ").append(userName).append(" reconnected - userId = ").append(userId.toString()).toString()); + logger.info("Reconnected user " + userName + " id: " + userId); } } @@ -327,23 +327,23 @@ public class User { } public void kill(DisconnectReason reason) { - logger.debug("user.kill before game session " + gameSessions.size() ); + logger.debug("game sessions: " + gameSessions.size() ); for (GameSession gameSession: gameSessions.values()) { gameSession.kill(); } - logger.debug("user.kill before draft session " + draftSessions.size()); + logger.debug("draft sessions " + draftSessions.size()); for (DraftSession draftSession: draftSessions.values()) { draftSession.setKilled(); } - logger.debug("user.kill before tournament session " + tournamentSessions.size()); + logger.debug("tournament sessions " + tournamentSessions.size()); for (TournamentSession tournamentSession: tournamentSessions.values()) { tournamentSession.setKilled(); } - logger.debug("user.kill before tables " + tables.size()); + logger.debug("tables " + tables.size()); for (Entry entry: tables.entrySet()) { TableManager.getInstance().leaveTable(userId, entry.getValue().getId()); } - logger.debug("user.kill before chat remove user"); + logger.debug("chat remove user"); ChatManager.getInstance().removeUser(userId, reason); } @@ -396,22 +396,22 @@ public class User { } } if (match > 0) { - sb.append("MP: ").append(match).append(" "); + sb.append("Match: ").append(match).append(" "); } if (sideboard > 0) { - sb.append("MS: ").append(sideboard).append(" "); + sb.append("Sideb: ").append(sideboard).append(" "); } if (draft > 0) { - sb.append("TD: ").append(draft).append(" "); + sb.append("Draft: ").append(draft).append(" "); } if (construct > 0) { - sb.append("TC: ").append(construct).append(" "); + sb.append("Const: ").append(construct).append(" "); } if (tournament > 0) { - sb.append("TP: ").append(tournament).append(" "); + sb.append("Tourn: ").append(tournament).append(" "); } if (watchedGames.size() > 0) { - sb.append("WA: ").append(watchedGames.size()).append(" "); + sb.append("Watch: ").append(watchedGames.size()).append(" "); } sb.append(disconnectInfo); @@ -433,4 +433,9 @@ public class User { public void removeGameWatchInfo(UUID gameId) { watchedGames.remove(gameId); } + + public UserState getUserState() { + return userState; + } + } diff --git a/Mage.Server/src/main/java/mage/server/UserManager.java b/Mage.Server/src/main/java/mage/server/UserManager.java index 3c5db1a7e3..59f96da445 100644 --- a/Mage.Server/src/main/java/mage/server/UserManager.java +++ b/Mage.Server/src/main/java/mage/server/UserManager.java @@ -125,14 +125,11 @@ public class UserManager { public void removeUser(UUID userId, DisconnectReason reason) { User user = users.get(userId); if (user != null) { - logger.debug(new StringBuilder("Remove user: ").append(user.getName()) - .append(" userId: ").append(userId) - .append(" sessionId: ").append(user.getSessionId()) - .append(" Reason: ").append(reason.toString())); + logger.debug(user.getName() + " " + reason.toString() + "userId: " + userId); user.kill(reason); users.remove(userId); } else { - logger.warn(new StringBuilder("Trying to remove userId: ").append(userId).append(" but user does not exist.")); + logger.warn(new StringBuilder("Trying to remove userId: ").append(userId).append(" but it does not exist.")); } } diff --git a/Mage.Server/src/main/java/mage/server/game/GameController.java b/Mage.Server/src/main/java/mage/server/game/GameController.java index 6533b1df41..cfc801cec2 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameController.java +++ b/Mage.Server/src/main/java/mage/server/game/GameController.java @@ -106,7 +106,7 @@ public class GameController implements GameCallback { } public void cleanUp() { - ChatManager.getInstance().destroyChatSession(chatId); + // nothing now } private void init() { diff --git a/Mage.Server/src/main/resources/log4j.properties b/Mage.Server/src/main/resources/log4j.properties index 5350776b51..268c9a3495 100644 --- a/Mage.Server/src/main/resources/log4j.properties +++ b/Mage.Server/src/main/resources/log4j.properties @@ -2,23 +2,26 @@ log4j.rootLogger=info, console, logfile log4j.logger.com.j256.ormlite=warn #log4j.logger.mage.player.ai=TRACE +log4j.logger.mage.player.ai=warn #log4j.logger.mage.player.ai.ComputerPlayer6=debug #log4j.logger.mage.player.ai.ComputerPlayer7=debug #log4j.logger.mage.player.ai.GameStateEvaluator2=debug #log4j.logger.mage.player.human=DEBUG, console, logfile #log4j.additivity.mage.player.human=false +log4j.logger.mage.server=debug #console log log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout -log4j.appender.console.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n +#log4j.appender.console.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n +log4j.appender.console.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M%n log4j.appender.console.Threshold=DEBUG #file log log4j.appender.logfile=org.apache.log4j.FileAppender log4j.appender.logfile.File=mageserver.log log4j.appender.logfile.layout=org.apache.log4j.PatternLayout -log4j.appender.logfile.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n +log4j.appender.logfile.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M%n #diagnostic log for game core classes log4j.category.mage.server.game = INFO, diagfile diff --git a/Mage/src/mage/game/GameImpl.java b/Mage/src/mage/game/GameImpl.java index e3a442d512..1a318e89c7 100644 --- a/Mage/src/mage/game/GameImpl.java +++ b/Mage/src/mage/game/GameImpl.java @@ -620,7 +620,7 @@ public abstract class GameImpl implements Game, Serializable { } if (gameOver(null)) { winnerId = findWinnersAndLosers(); - logger.info(new StringBuilder("Game with gameId ").append(this.getId()).append(" ended.")); + logger.info("GAME ended gameId: " + this.getId()); } }