* Changes to logging.

This commit is contained in:
LevelX2 2014-08-03 15:01:33 +02:00
parent 9bcbdbb73d
commit 9f6555240a
10 changed files with 57 additions and 23 deletions

View file

@ -1,5 +1,5 @@
#default levels #default levels
log4j.rootLogger=debug, console, logfile log4j.rootLogger=info, console, logfile
#console log #console log
log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console=org.apache.log4j.ConsoleAppender

View file

@ -5,10 +5,10 @@ log4j.logger.com.j256.ormlite=warn
#log4j.logger.org.jboss.remoting=debug #log4j.logger.org.jboss.remoting=debug
#log4j.logger.org.jboss.logging=debug #log4j.logger.org.jboss.logging=debug
log4j.logger.mage.player.ai.ComputerPlayer6=debug #log4j.logger.mage.player.ai.ComputerPlayer6=debug
log4j.logger.mage.client.remote.CallbackClientImpl=debug
#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.remote.CallbackClientImpl=debug
#log4j.logger.mage.client.game.FeedbackPanel=debug
#console log #console log
log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console=org.apache.log4j.ConsoleAppender

View file

@ -28,6 +28,7 @@
package mage.server; package mage.server;
import java.util.ArrayList;
import java.util.Locale; import java.util.Locale;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -176,4 +177,10 @@ public class ChatManager {
} }
Logger.getLogger(ChatManager.class).debug("ChatManager: Remove user end"); Logger.getLogger(ChatManager.class).debug("ChatManager: Remove user end");
} }
public ArrayList<ChatSession> getChatSessions() {
ArrayList<ChatSession> chatSessionList = new ArrayList<>();
chatSessionList.addAll(chatSessions.values());
return chatSessionList;
}
} }

View file

@ -69,10 +69,10 @@ public class ChatSession {
try { try {
if (userId != null && clients.containsKey(userId)) { if (userId != null && clients.containsKey(userId)) {
String userName = clients.get(userId);
clients.remove(userId); clients.remove(userId);
logger.debug("ChatSession.kill chatSession: " + chatId + " userId: " + userId + " reason: " + (reason == null?"null":reason.toString()) logger.debug("ChatSession.kill chatSession: " + chatId + " userId: " + userId + " reason: " + (reason == null?"null":reason.toString())
+ " clients.size " + clients.size()); + " clients.size " + clients.size());
String userName = clients.get(userId);
String message = null; String message = null;
switch (reason) { switch (reason) {
case Disconnected: case Disconnected:
@ -90,7 +90,7 @@ public class ChatSession {
} }
} }
} catch(Exception ex) { } catch(Exception ex) {
logger.fatal(ex); logger.fatal("ChatSession.kill exception: " + ex.toString());
} }
} }
@ -157,4 +157,7 @@ public class ChatSession {
return clients.containsKey(userId); return clients.containsKey(userId);
} }
public ConcurrentHashMap<UUID, String> getClients() {
return clients;
}
} }

View file

@ -72,7 +72,7 @@ public class TableManager {
* *
* In minutes. * In minutes.
*/ */
private static final int EXPIRE_CHECK_PERIOD = 10; private static final int EXPIRE_CHECK_PERIOD = 5;
/** /**
* This parameters defines when table can be counted as expired. * This parameters defines when table can be counted as expired.
@ -355,7 +355,21 @@ public class TableManager {
} }
private void checkExpired() { private void checkExpired() {
logger.debug("Table expire checking..."); logger.debug("--- Table expire checking -----------------------------------------------------------------------");
Collection<User> users = UserManager.getInstance().getUsers();
logger.debug("------- Users: " + users.size() + " ------------------------");
for (User user :users) {
logger.debug(user.getName() + " SessionId: " + user.getSessionId() + " ConnectionTime: " + user.getConnectionTime());
}
ArrayList<ChatSession> chatSessions = ChatManager.getInstance().getChatSessions();
logger.debug("------- ChatSessions: " + chatSessions.size() + " ------------------------");
for (ChatSession chatSession: chatSessions) {
logger.debug(chatSession.getChatId() + " Clients: " + chatSession.getClients().values().toString());
}
logger.debug("------- Tables: " + tables.size() + " ------------------------");
for (Table table: tables.values()) {
logger.debug(table.getId() + " Name: [" + table.getName()+ "] StartTime: " + table.getStartTime());
}
Date now = new Date(); Date now = new Date();
List<UUID> toRemove = new ArrayList<>(); List<UUID> toRemove = new ArrayList<>();

View file

@ -123,11 +123,11 @@ public class GameController implements GameCallback {
break; break;
case INFO: case INFO:
ChatManager.getInstance().broadcast(chatId, "", event.getMessage(), MessageColor.BLACK, true, ChatMessage.MessageType.GAME); ChatManager.getInstance().broadcast(chatId, "", event.getMessage(), MessageColor.BLACK, true, ChatMessage.MessageType.GAME);
logger.debug(game.getId() + " " + event.getMessage()); logger.trace(game.getId() + " " + event.getMessage());
break; break;
case STATUS: case STATUS:
ChatManager.getInstance().broadcast(chatId, "", event.getMessage(), MessageColor.ORANGE, event.getWithTime(), ChatMessage.MessageType.GAME); ChatManager.getInstance().broadcast(chatId, "", event.getMessage(), MessageColor.ORANGE, event.getWithTime(), ChatMessage.MessageType.GAME);
logger.debug(game.getId() + " " + event.getMessage()); logger.trace(game.getId() + " " + event.getMessage());
break; break;
case ERROR: case ERROR:
error(event.getMessage(), event.getException()); error(event.getMessage(), event.getException());

View file

@ -73,7 +73,12 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
updateExecutor.scheduleAtFixedRate(new Runnable() { updateExecutor.scheduleAtFixedRate(new Runnable() {
@Override @Override
public void run(){ public void run(){
try {
update(); update();
} catch (Exception ex) {
logger.fatal("Games room update exception!", ex);
}
} }
}, 2, 2, TimeUnit.SECONDS); }, 2, 2, TimeUnit.SECONDS);
} }

View file

@ -165,12 +165,17 @@ public class TournamentController {
// first join of player // first join of player
TournamentSession tournamentSession = new TournamentSession(tournament, userId, tableId, playerId); TournamentSession tournamentSession = new TournamentSession(tournament, userId, tableId, playerId);
tournamentSessions.put(playerId, tournamentSession); tournamentSessions.put(playerId, tournamentSession);
UserManager.getInstance().getUser(userId).addTournament(playerId, tournamentSession); User user = UserManager.getInstance().getUser(userId);
if (user != null) {
user.addTournament(playerId, tournamentSession);
TournamentPlayer player = tournament.getPlayer(playerId); TournamentPlayer player = tournament.getPlayer(playerId);
player.setJoined(); player.setJoined();
logger.debug("player " +player.getPlayer().getName() + " - client has joined tournament " + tournament.getId()); logger.debug("player " +player.getPlayer().getName() + " - client has joined tournament " + tournament.getId());
ChatManager.getInstance().broadcast(chatId, "", player.getPlayer().getName() + " has joined the tournament", MessageColor.BLACK, true, MessageType.STATUS); ChatManager.getInstance().broadcast(chatId, "", player.getPlayer().getName() + " has joined the tournament", MessageColor.BLACK, true, MessageType.STATUS);
checkStart(); checkStart();
} else {
logger.error("TournamentController.join user not found uderId: " +userId + " tournamentId: " + tournament.getId());
}
} }
private void checkStart() { private void checkStart() {

View file

@ -48,7 +48,7 @@ public class GameStates implements Serializable {
public void save(GameState gameState) { public void save(GameState gameState) {
// states.add(new Copier<GameState>().copyCompressed(gameState)); // states.add(new Copier<GameState>().copyCompressed(gameState));
states.add(gameState.copy()); states.add(gameState.copy());
logger.debug("Saved game state: " + states.size()); logger.trace("Saved game state: " + states.size());
} }
public int getSize() { public int getSize() {

View file

@ -1562,14 +1562,14 @@ public abstract class PlayerImpl implements Player, Serializable {
public void passTurnPriority(Game game) { public void passTurnPriority(Game game) {
passedTurn = true; passedTurn = true;
this.skip(); this.skip();
log.debug("Passed priority for turn"); log.trace("Passed priority for turn");
} }
@Override @Override
public void restorePriority(Game game) { public void restorePriority(Game game) {
passedAllTurns = false; passedAllTurns = false;
passedTurn = false; passedTurn = false;
log.debug("Restore priority"); log.trace("Restore priority");
} }
@Override @Override