mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
* Changes to logging.
This commit is contained in:
parent
9bcbdbb73d
commit
9f6555240a
10 changed files with 57 additions and 23 deletions
|
@ -1,5 +1,5 @@
|
|||
#default levels
|
||||
log4j.rootLogger=debug, console, logfile
|
||||
log4j.rootLogger=info, console, logfile
|
||||
|
||||
#console log
|
||||
log4j.appender.console=org.apache.log4j.ConsoleAppender
|
||||
|
|
|
@ -5,10 +5,10 @@ log4j.logger.com.j256.ormlite=warn
|
|||
|
||||
#log4j.logger.org.jboss.remoting=debug
|
||||
#log4j.logger.org.jboss.logging=debug
|
||||
log4j.logger.mage.player.ai.ComputerPlayer6=debug
|
||||
log4j.logger.mage.client.remote.CallbackClientImpl=debug
|
||||
#log4j.logger.mage.player.ai.ComputerPlayer6=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
|
||||
log4j.appender.console=org.apache.log4j.ConsoleAppender
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
package mage.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
@ -176,4 +177,10 @@ public class ChatManager {
|
|||
}
|
||||
Logger.getLogger(ChatManager.class).debug("ChatManager: Remove user end");
|
||||
}
|
||||
|
||||
public ArrayList<ChatSession> getChatSessions() {
|
||||
ArrayList<ChatSession> chatSessionList = new ArrayList<>();
|
||||
chatSessionList.addAll(chatSessions.values());
|
||||
return chatSessionList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,10 +69,10 @@ public class ChatSession {
|
|||
|
||||
try {
|
||||
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());
|
||||
String userName = clients.get(userId);
|
||||
String message = null;
|
||||
switch (reason) {
|
||||
case Disconnected:
|
||||
|
@ -90,7 +90,7 @@ public class ChatSession {
|
|||
}
|
||||
}
|
||||
} catch(Exception ex) {
|
||||
logger.fatal(ex);
|
||||
logger.fatal("ChatSession.kill exception: " + ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,4 +157,7 @@ public class ChatSession {
|
|||
return clients.containsKey(userId);
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<UUID, String> getClients() {
|
||||
return clients;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public class TableManager {
|
|||
*
|
||||
* 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.
|
||||
|
@ -355,7 +355,21 @@ public class TableManager {
|
|||
}
|
||||
|
||||
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();
|
||||
List<UUID> toRemove = new ArrayList<>();
|
||||
|
|
|
@ -123,11 +123,11 @@ public class GameController implements GameCallback {
|
|||
break;
|
||||
case INFO:
|
||||
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;
|
||||
case STATUS:
|
||||
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;
|
||||
case ERROR:
|
||||
error(event.getMessage(), event.getException());
|
||||
|
|
|
@ -73,7 +73,12 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
|||
updateExecutor.scheduleAtFixedRate(new Runnable() {
|
||||
@Override
|
||||
public void run(){
|
||||
try {
|
||||
update();
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("Games room update exception!", ex);
|
||||
}
|
||||
|
||||
}
|
||||
}, 2, 2, TimeUnit.SECONDS);
|
||||
}
|
||||
|
|
|
@ -165,12 +165,17 @@ public class TournamentController {
|
|||
// first join of player
|
||||
TournamentSession tournamentSession = new TournamentSession(tournament, userId, tableId, playerId);
|
||||
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);
|
||||
player.setJoined();
|
||||
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);
|
||||
checkStart();
|
||||
} else {
|
||||
logger.error("TournamentController.join user not found uderId: " +userId + " tournamentId: " + tournament.getId());
|
||||
}
|
||||
}
|
||||
|
||||
private void checkStart() {
|
||||
|
|
|
@ -48,7 +48,7 @@ public class GameStates implements Serializable {
|
|||
public void save(GameState gameState) {
|
||||
// states.add(new Copier<GameState>().copyCompressed(gameState));
|
||||
states.add(gameState.copy());
|
||||
logger.debug("Saved game state: " + states.size());
|
||||
logger.trace("Saved game state: " + states.size());
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
|
|
|
@ -1562,14 +1562,14 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
public void passTurnPriority(Game game) {
|
||||
passedTurn = true;
|
||||
this.skip();
|
||||
log.debug("Passed priority for turn");
|
||||
log.trace("Passed priority for turn");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restorePriority(Game game) {
|
||||
passedAllTurns = false;
|
||||
passedTurn = false;
|
||||
log.debug("Restore priority");
|
||||
log.trace("Restore priority");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue