server: improved logs for some use cases (related to #11572)

This commit is contained in:
Oleg Agafonov 2023-12-28 00:30:07 +04:00
parent fac5f8c752
commit e79f562f4a
4 changed files with 20 additions and 8 deletions

View file

@ -19,6 +19,7 @@ import mage.interfaces.callback.ClientCallback;
import mage.interfaces.callback.ClientCallbackType;
import mage.remote.ActionData;
import mage.remote.Session;
import mage.util.DebugUtil;
import mage.view.*;
import mage.view.ChatMessage.MessageType;
import org.apache.log4j.Logger;
@ -34,8 +35,6 @@ public class CallbackClientImpl implements CallbackClient {
private static final Logger logger = Logger.getLogger(CallbackClientImpl.class);
private static final boolean DEBUG_CALLBACK_MESSAGES_LOG = false; // show all callback messages (server commands)
private final MageFrame frame;
private final Map<ClientCallbackType, Integer> lastMessages;
private final Map<UUID, GameClientMessage> firstGameData;
@ -71,7 +70,7 @@ public class CallbackClientImpl implements CallbackClient {
// all GUI related code must be executed in swing thread
SwingUtilities.invokeLater(() -> {
try {
if (DEBUG_CALLBACK_MESSAGES_LOG) {
if (DebugUtil.NETWORK_SHOW_CLIENT_CALLBACK_MESSAGES_LOG) {
logger.info("message " + callback.getMessageId() + " - " + callback.getMethod().getType() + " - " + callback.getMethod());
}

View file

@ -211,16 +211,18 @@ public class HumanPlayer extends PlayerImpl {
// game frozen, possible reasons:
// * ANOTHER player lost connection and GAME thread trying to send data to him
// * current player send answer, but lost connect after it
// * game thread stops and lost
String possibleReason;
if (response.getActiveAction() == null) {
possibleReason = "maybe connection problem with another player/watcher";
} else {
possibleReason = "something wrong with your priority on " + response.getActiveAction();
}
logger.warn(String.format("Game frozen in waitResponseOpen for %d secs: current user %s, %s",
logger.warn(String.format("Game frozen in waitResponseOpen for %d secs. User: %s; reason: %s; game: %s",
RESPONSE_WAITING_CHECK_MS * currentTimesWaiting / 1000,
this.getName(),
possibleReason
possibleReason,
response.getActiveGameInfo()
));
return false;
}
@ -308,7 +310,7 @@ public class HumanPlayer extends PlayerImpl {
while (loop) {
// start waiting for next answer
response.clear();
response.setActiveAction(DebugUtil.getMethodNameWithSource(2));
response.setActiveAction(game, DebugUtil.getMethodNameWithSource(2));
game.resumeTimer(getTurnControlledBy());
responseOpenedForAnswer = true;

View file

@ -1,6 +1,7 @@
package mage.player.human;
import mage.constants.ManaType;
import mage.game.Game;
import mage.util.Copyable;
import java.io.Serializable;
@ -20,7 +21,8 @@ import java.util.UUID;
*/
public class PlayerResponse implements Serializable, Copyable<PlayerResponse> {
private String activeAction; // for debug information
private String activeAction; // for logs/debug information
private String activeGameInfo; // for logs/debug info
private String responseString;
private UUID responseUUID;
@ -64,6 +66,7 @@ public class PlayerResponse implements Serializable, Copyable<PlayerResponse> {
public void copyFrom(final PlayerResponse response) {
this.activeAction = response.activeAction;
this.activeGameInfo = response.activeGameInfo;
this.responseString = response.responseString;
this.responseUUID = response.responseUUID;
this.responseBoolean = response.responseBoolean;
@ -76,6 +79,7 @@ public class PlayerResponse implements Serializable, Copyable<PlayerResponse> {
public void clear() {
this.activeAction = null;
this.activeGameInfo = null;
this.responseString = null;
this.responseUUID = null;
this.responseBoolean = null;
@ -90,8 +94,13 @@ public class PlayerResponse implements Serializable, Copyable<PlayerResponse> {
return this.activeAction;
}
public void setActiveAction(String activeAction) {
public String getActiveGameInfo() {
return this.activeGameInfo;
}
public void setActiveAction(Game game, String activeAction) {
this.activeAction = activeAction;
this.activeGameInfo = game.getId() + ", " + game;
}
public String getString() {

View file

@ -11,6 +11,8 @@ import java.lang.reflect.Method;
*/
public class DebugUtil {
public static boolean NETWORK_SHOW_CLIENT_CALLBACK_MESSAGES_LOG = false; // show all callback messages (server commands)
// cards basic (card panels)
public static boolean GUI_CARD_DRAW_OUTER_BORDER = false;
public static boolean GUI_CARD_DRAW_INNER_BORDER = false;