From a7acc37395879efc8345d9f7b46aea32f448d2a7 Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 24 Aug 2020 12:10:25 -0700 Subject: [PATCH] adding logging --- .../java/org/eehouse/android/xw4/BoardDelegate.java | 3 +++ xwords4/common/comms.c | 2 +- xwords4/common/server.c | 11 ++++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java index a3c1243ce..518a59967 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java @@ -1831,6 +1831,7 @@ public class BoardDelegate extends DelegateBase @Override public void setIsServer( boolean isServer ) { + Log.d( TAG, "setIsServer(isServer=%b)", isServer ); DeviceRole newRole = isServer? DeviceRole.SERVER_ISSERVER : DeviceRole.SERVER_ISCLIENT; if ( newRole != m_gi.serverRole ) { @@ -1838,6 +1839,8 @@ public class BoardDelegate extends DelegateBase if ( !isServer ) { handleViaThread( JNICmd.CMD_SWITCHCLIENT ); } + } else { + Log.d( TAG, "setIsServer(): no change" ); } } diff --git a/xwords4/common/comms.c b/xwords4/common/comms.c index c5c4a7151..09fdb2880 100644 --- a/xwords4/common/comms.c +++ b/xwords4/common/comms.c @@ -1762,7 +1762,7 @@ got_connect_cmd( CommsCtxt* comms, XWEnv xwe, XWStreamCtxt* stream, isServer = HOST_ID_SERVER == comms->rr.myHostID; if ( isServer != comms->isServer ) { - XP_LOGF( "%s: becoming%s a server", __func__, isServer ? "" : " NOT" ); + XP_LOGFF( "becoming%s a server", isServer ? "" : " NOT" ); comms->isServer = isServer; util_setIsServer( comms->util, xwe, comms->isServer ); diff --git a/xwords4/common/server.c b/xwords4/common/server.c index d46c46378..a2b269c41 100644 --- a/xwords4/common/server.c +++ b/xwords4/common/server.c @@ -207,6 +207,8 @@ static void writeProto( const ServerCtxt* server, XWStreamCtxt* stream, #define PICK_NEXT -1 #define PICK_CUR -2 +#define LOG_GAMEID() XP_LOGFF("gameID: %d", server->vol.gi->gameID ) + #if defined DEBUG && ! defined XWFEATURE_STANDALONE_ONLY static char* getStateStr( XW_State st ) @@ -290,6 +292,7 @@ amServer( const ServerCtxt* server ) static void initServer( ServerCtxt* server, XWEnv xwe ) { + LOG_GAMEID(); setTurn( server, xwe, -1 ); /* game isn't under way yet */ if ( 0 ) { @@ -585,6 +588,7 @@ cleanupServer( ServerCtxt* server, XWEnv xwe ) void server_reset( ServerCtxt* server, XWEnv xwe, CommsCtxt* comms ) { + LOG_GAMEID(); ServerVolatiles vol = server->vol; cleanupServer( server, xwe ); @@ -744,8 +748,8 @@ server_initClientConnection( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream #endif } else { - XP_LOGF( "%s: wierd state: %s (expected XWSTATE_NONE); dropping message", - __func__, getStateStr(server->nv.gameState) ); + XP_LOGFF( "wierd state: %s (expected XWSTATE_NONE); dropping message", + getStateStr(server->nv.gameState) ); } stream_destroy( stream, xwe ); return result; @@ -1612,7 +1616,8 @@ server_do( ServerCtxt* server, XWEnv xwe ) } else { XP_Bool moreToDo = XP_FALSE; server->serverDoing = XP_TRUE; - XP_LOGFF( "gameState: %s", getStateStr(server->nv.gameState) ); + XP_LOGFF( "gameState: %s; gameID: %d", getStateStr(server->nv.gameState), + server->vol.gi->gameID ); switch( server->nv.gameState ) { case XWSTATE_BEGIN: if ( server->nv.pendingRegistrations == 0 ) { /* all players on