mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-22 07:28:16 +01:00
introduce XP_LOGFFV and use it to remove some excessive logging
This commit is contained in:
parent
5adedac314
commit
8487d212a3
5 changed files with 41 additions and 22 deletions
|
@ -876,7 +876,7 @@ msgAndTopicProc( void* closure, const XP_UCHAR* topic,
|
|||
mtp->jPackets[mtp->count] = makeByteArray( env, msgLen, (const jbyte*)msgBuf );
|
||||
|
||||
++mtp->count;
|
||||
XP_LOGFF( "mtp->count now: %d", mtp->count );
|
||||
XP_LOGFFV( "mtp->count now: %d", mtp->count );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,13 +55,13 @@ passTAPToAndroid( AndTransportProcs* aprocs, JNIEnv* env, jobject jtap )
|
|||
{
|
||||
const char* sig = "(L" PKG_PATH("jni/XwJNI$TopicsAndPackets") ";)I";
|
||||
jmethodID mid = getMethodID( env, aprocs->jxport, "transportSendMQTT", sig );
|
||||
#ifdef DEBUG
|
||||
#ifdef ENABLE_LOGFFV
|
||||
XP_S16 tmp =
|
||||
#endif
|
||||
(*env)->CallIntMethod( env, aprocs->jxport, mid, jtap );
|
||||
XP_LOGFF( "%s() => %d", sig, tmp );
|
||||
XP_LOGFFV( "%s() => %d", sig, tmp );
|
||||
deleteLocalRef( env, jtap );
|
||||
LOG_RETURN_VOID();
|
||||
XP_LOGFFV();
|
||||
}
|
||||
|
||||
#ifdef XWFEATURE_COMMS_INVITE
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*- compile-command: "cd ../linux && make MEMDEBUG=TRUE -j3"; -*- */
|
||||
/*
|
||||
* Copyright 2001 - 2023 by Eric House (xwords@eehouse.org). All rights
|
||||
* Copyright 2001 - 2024 by Eric House (xwords@eehouse.org). All rights
|
||||
* reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -18,6 +18,8 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
// #define ENABLE_LOGFFV
|
||||
|
||||
#ifdef USE_STDIO
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
|
@ -60,7 +62,12 @@
|
|||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
# define COMMS_LOGFF( FMT, ... ) { \
|
||||
# ifdef ENABLE_LOGFFV
|
||||
# define COMMS_LOGFFV COMMS_LOGFF
|
||||
# else
|
||||
# define COMMS_LOGFFV(...)
|
||||
# endif
|
||||
# define COMMS_LOGFF( FMT, ... ) { \
|
||||
XP_U32 gameID = comms->util->gameInfo->gameID; \
|
||||
XP_GID_LOGFF( gameID, FMT, ##__VA_ARGS__ ); \
|
||||
}
|
||||
|
@ -836,7 +843,7 @@ comms_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream,
|
|||
}
|
||||
if ( addr_hasType( &selfAddr, COMMS_CONN_RELAY ) ) {
|
||||
comms->rr.myHostID = stream_getU8( stream );
|
||||
COMMS_LOGFF( "loaded myHostID: %d", comms->rr.myHostID );
|
||||
COMMS_LOGFFV( "loaded myHostID: %d", comms->rr.myHostID );
|
||||
stringFromStreamHere( stream, comms->rr.connName,
|
||||
sizeof(comms->rr.connName) );
|
||||
}
|
||||
|
@ -844,7 +851,7 @@ comms_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream,
|
|||
XP_U16 queueLen = stream_getU8( stream );
|
||||
|
||||
XP_U16 nAddrRecs = stream_getU8( stream );
|
||||
COMMS_LOGFF( "nAddrRecs: %d", nAddrRecs );
|
||||
COMMS_LOGFFV( "nAddrRecs: %d", nAddrRecs );
|
||||
AddressRecord** prevsAddrNext = &comms->recs;
|
||||
for ( int ii = 0; ii < nAddrRecs; ++ii ) {
|
||||
AddressRecord* rec = (AddressRecord*)XP_CALLOC( mpool, sizeof(*rec));
|
||||
|
@ -861,7 +868,7 @@ comms_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream,
|
|||
rec->lastMsgSaved = rec->lastMsgRcd = stream_getU16( stream );
|
||||
}
|
||||
#ifdef LOG_COMMS_MSGNOS
|
||||
COMMS_LOGFF( "read lastMsgRcd of %d for addr %d", rec->lastMsgRcd, ii );
|
||||
COMMS_LOGFFV( "read lastMsgRcd of %d for addr %d", rec->lastMsgRcd, ii );
|
||||
#endif
|
||||
if ( version >= STREAM_VERS_BLUETOOTH2 ) {
|
||||
rec->lastMsgAckd = stream_getU16( stream );
|
||||
|
@ -872,7 +879,7 @@ comms_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream,
|
|||
}
|
||||
|
||||
CNO_FMT( cbuf, rec->channelNo );
|
||||
COMMS_LOGFF( "loaded rec %d: %s", ii, cbuf );
|
||||
COMMS_LOGFFV( "loaded rec %d: %s", ii, cbuf );
|
||||
|
||||
*prevsAddrNext = rec;
|
||||
prevsAddrNext = &rec->next;
|
||||
|
@ -2007,8 +2014,8 @@ removeFromQueue( CommsCtxt* comms, XWEnv xwe, XP_PlayerAddr channelNo, MsgID msg
|
|||
THREAD_CHECK_START( comms );
|
||||
assertQueueOk( comms );
|
||||
CNO_FMT( cbuf, channelNo );
|
||||
COMMS_LOGFF( "(channelNo=%d): remove msgs <= " XP_LD " for %s (queueLen: %d)",
|
||||
channelNo, msgID, cbuf, comms->queueLen );
|
||||
COMMS_LOGFFV( "(channelNo=%d): remove msgs <= " XP_LD " for %s (queueLen: %d)",
|
||||
channelNo, msgID, cbuf, comms->queueLen );
|
||||
#ifdef DEBUG
|
||||
XP_U16 prevLen = comms->queueLen;
|
||||
#endif
|
||||
|
@ -2026,7 +2033,7 @@ removeFromQueue( CommsCtxt* comms, XWEnv xwe, XP_PlayerAddr channelNo, MsgID msg
|
|||
}
|
||||
|
||||
XP_ASSERT( comms->queueLen <= prevLen );
|
||||
COMMS_LOGFF( "queueLen now %d (was %d)", comms->queueLen, prevLen );
|
||||
COMMS_LOGFFV( "queueLen now %d (was %d)", comms->queueLen, prevLen );
|
||||
|
||||
#ifdef DEBUG
|
||||
assertQueueOk( comms );
|
||||
|
@ -2740,8 +2747,8 @@ getRecordFor( const CommsCtxt* comms, const XP_PlayerAddr channelNo )
|
|||
XP_ASSERT( comms->isServer || !rec->next );
|
||||
|
||||
CNO_FMT( cbuf1, rec->channelNo );
|
||||
COMMS_LOGFF( "comparing rec channel %s with addr channel %s",
|
||||
cbuf1, cbuf );
|
||||
COMMS_LOGFFV( "comparing rec channel %s with addr channel %s",
|
||||
cbuf1, cbuf );
|
||||
|
||||
/* Invite case: base on channelNo bits if the rest is 0 */
|
||||
if ( (0 == (rec->channelNo & ~CHANNEL_MASK)) && (0 == (channelNo & ~CHANNEL_MASK)) ) {
|
||||
|
@ -2749,14 +2756,14 @@ getRecordFor( const CommsCtxt* comms, const XP_PlayerAddr channelNo )
|
|||
break;
|
||||
}
|
||||
} else if ( (rec->channelNo & ~CHANNEL_MASK) == (channelNo & ~CHANNEL_MASK) ) {
|
||||
COMMS_LOGFF( "match based on channels!!!" );
|
||||
COMMS_LOGFFV( "match based on channels!!!" );
|
||||
/* This is so wrong for addresses coming from invites. Why works
|
||||
with GTK? */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
COMMS_LOGFF( "(%s) => %p", cbuf, rec );
|
||||
COMMS_LOGFFV( "(%s) => %p", cbuf, rec );
|
||||
return rec;
|
||||
} /* getRecordFor */
|
||||
|
||||
|
@ -2927,7 +2934,7 @@ validateChannelMessage( CommsCtxt* comms, XWEnv xwe, const CommsAddrRec* addr,
|
|||
/* an ACK; do nothing */
|
||||
rec = NULL;
|
||||
} else if ( msgID == rec->lastMsgRcd + 1 ) {
|
||||
COMMS_LOGFF( TAGFMT() "expected %d AND got %d", TAGPRMS,
|
||||
COMMS_LOGFFV( TAGFMT() "expected %d AND got %d", TAGPRMS,
|
||||
msgID, msgID );
|
||||
} else {
|
||||
COMMS_LOGFF( TAGFMT() "expected %d, got %d", TAGPRMS,
|
||||
|
|
|
@ -410,6 +410,16 @@ typedef struct _TrayTileSet {
|
|||
#define LOG_POS(strm) XP_LOGF( "%s(); line %d; read_pos: %X", __func__, __LINE__, \
|
||||
stream_getPos((strm), POS_READ) )
|
||||
|
||||
/* The idea is that an individual .c file needing logging when being debugged
|
||||
but not wanting to flood the logs in the normal case uses XP_LOGFFV in
|
||||
place of XP_LOGFF, and then #defines ENABLE_LOGFFV at the very top of itself
|
||||
(before any #includes). */
|
||||
#ifdef ENABLE_LOGFFV
|
||||
# define XP_LOGFFV XP_LOGFF
|
||||
#else
|
||||
# define XP_LOGFFV(...)
|
||||
#endif
|
||||
|
||||
#ifndef XP_USE
|
||||
# define XP_USE(v) v=v
|
||||
#endif
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
// #define ENABLE_LOGFFV 1
|
||||
|
||||
#include "knownplyr.h"
|
||||
#include "strutils.h"
|
||||
#include "comms.h"
|
||||
|
@ -160,7 +162,7 @@ makeUniqueName( const KPState* state, const XP_UCHAR* name,
|
|||
break;
|
||||
}
|
||||
}
|
||||
XP_LOGFF( "created new name: %s", newName );
|
||||
XP_LOGFFV( "created new name: %s", newName );
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -256,14 +258,14 @@ addPlayer( XW_DUtilCtxt* XP_UNUSED_DBG(dutil), KPState* state,
|
|||
&newPlayer->links, compByName );
|
||||
state->dirty = XP_TRUE;
|
||||
}
|
||||
XP_LOGFF( "nPlayers now: %d", dll_length( &state->players->links ) );
|
||||
XP_LOGFFV( "nPlayers now: %d", dll_length( &state->players->links ) );
|
||||
}
|
||||
|
||||
XP_Bool
|
||||
kplr_addAddrs( XW_DUtilCtxt* dutil, XWEnv xwe, const CurGameInfo* gi,
|
||||
CommsAddrRec addrs[], XP_U16 nAddrs, XP_U32 modTime )
|
||||
{
|
||||
XP_LOGFF( "(nAddrs=%d)", nAddrs );
|
||||
XP_LOGFFV( "(nAddrs=%d)", nAddrs );
|
||||
XP_ASSERT( modTime );
|
||||
XP_Bool canUse = XP_TRUE;
|
||||
for ( int ii = 0; ii < nAddrs && canUse; ++ii ) {
|
||||
|
@ -286,7 +288,7 @@ kplr_addAddrs( XW_DUtilCtxt* dutil, XWEnv xwe, const CurGameInfo* gi,
|
|||
releaseState( dutil, xwe, state );
|
||||
}
|
||||
|
||||
LOG_RETURNF( "%s", boolToStr(canUse) );
|
||||
XP_LOGFFV( "=>%s", boolToStr(canUse) );
|
||||
return canUse;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue