Some changes to logging.

This commit is contained in:
LevelX2 2015-05-22 22:33:01 +02:00
parent ae89cef011
commit 64ea893ea0
3 changed files with 5 additions and 21 deletions

View file

@ -336,7 +336,7 @@ public class GameController implements GameCallback {
joinType = "rejoined"; joinType = "rejoined";
} }
user.addGame(playerId, gameSession); user.addGame(playerId, gameSession);
logger.debug("Player " + player.getLogName()+ " " + playerId + " has " + joinType + " gameId: " + game.getId()); logger.debug("Player " + player.getName()+ " " + playerId + " has " + joinType + " gameId: " + game.getId());
ChatManager.getInstance().broadcast(chatId, "", game.getPlayer(playerId).getLogName() + " has " + joinType + " the game", MessageColor.ORANGE, true, MessageType.GAME); ChatManager.getInstance().broadcast(chatId, "", game.getPlayer(playerId).getLogName() + " has " + joinType + " the game", MessageColor.ORANGE, true, MessageType.GAME);
checkStart(); checkStart();
} }

View file

@ -42,9 +42,7 @@ import java.util.UUID;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.game.Game; import mage.game.Game;
import mage.players.Player;
import mage.util.ThreadLocalStringBuilder; import mage.util.ThreadLocalStringBuilder;
import org.apache.log4j.Logger;
/** /**
@ -53,13 +51,11 @@ import org.apache.log4j.Logger;
*/ */
public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializable { public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializable {
private static final Logger logger = Logger.getLogger(CardsImpl.class);
private static final transient ThreadLocalStringBuilder threadLocalBuilder = new ThreadLocalStringBuilder(200); private static final transient ThreadLocalStringBuilder threadLocalBuilder = new ThreadLocalStringBuilder(200);
private static Random rnd = new Random(); private static Random rnd = new Random();
private UUID ownerId; private UUID ownerId;
private Zone zone; private Zone zone;
private boolean errorLogged = false;
public CardsImpl() { } public CardsImpl() { }
@ -200,21 +196,9 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
Set<Card> cards = new LinkedHashSet<>(); Set<Card> cards = new LinkedHashSet<>();
for (UUID cardId: this) { for (UUID cardId: this) {
Card card = game.getCard(cardId); Card card = game.getCard(cardId);
if (card != null) { if (card != null) { // this can happen during the cancelation (player concedes) of a game
cards.add(card); cards.add(card);
} else { }
if (!errorLogged) { // this runs in iteration, so the flag helps to stop to fill the log file
// seems like this can happen during the cancelation of a game
logger.error("Card not found cardId: " + cardId + " gameId: " + game.getId() );
for (Player player :game.getPlayers().values()) {
logger.error(player.getName() + " inGame=" + (player.isInGame() ? "true":"false"));
}
for (StackTraceElement stackTraceElement: Thread.currentThread().getStackTrace()) {
logger.error(stackTraceElement.toString());
}
errorLogged = true;
}
}
} }
return cards; return cards;
} }

View file

@ -1925,14 +1925,14 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public void lostForced(Game game) { public void lostForced(Game game) {
logger.debug(this.getLogName() + " has lost gameId: " + game.getId()); logger.debug(this.getName() + " has lost gameId: " + game.getId());
//20100423 - 603.9 //20100423 - 603.9
if (!this.wins) { if (!this.wins) {
this.loses = true; this.loses = true;
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.LOST, null, null, playerId)); game.fireEvent(GameEvent.getEvent(GameEvent.EventType.LOST, null, null, playerId));
game.informPlayers(this.getLogName() + " has lost the game."); game.informPlayers(this.getLogName() + " has lost the game.");
} else { } else {
logger.debug(this.getLogName() + " has already won - stop lost"); logger.debug(this.getName() + " has already won - stop lost");
} }
// for draw - first all players that have lost have to be set to lost // for draw - first all players that have lost have to be set to lost
if (!hasLeft()) { if (!hasLeft()) {