make it work on android too

This commit is contained in:
Eric House 2023-12-23 19:30:57 -08:00
parent 5794cc43e3
commit 9443bf14a4
3 changed files with 27 additions and 4 deletions

View file

@ -991,6 +991,23 @@ android_debugff(const char* func, const char* file, const char* fmt, ...)
va_end( ap );
}
void
android_gid_debugff( const XP_U32 gid, const char* func, const char* file,
const char* fmt, ...)
{
char buf[256];
const char* shortPath = 1 + strrchr(file, '/');
if ( !shortPath ) {
shortPath = file;
}
snprintf( buf, sizeof(buf), "<%08X> %s:%s(): %s", gid, shortPath, func, fmt );
va_list ap;
va_start( ap, fmt );
debugf( buf, ap );
va_end( ap );
}
/* Print an object's class name into buffer.
*
* NOTE: this must be called in advance of any jni error, because methods on

View file

@ -94,14 +94,20 @@ void and_assert( const char* test, int line, const char* file, const char* func
void android_debugf(const char*, ...) __attribute__ ((format (printf, 1, 2)));
void android_debugff(const char* func, const char* file, const char* fmt, ...)
__attribute__ ((format (printf, 3, 4)));
void android_gid_debugff(XP_U32 gid, const char* func, const char* file, const char* fmt, ...)
__attribute__ ((format (printf, 4, 5)));
#define XP_DEBUGF(...) android_debugf( __VA_ARGS__ )
#define XP_LOGF(...) android_debugf( __VA_ARGS__ )
#define XP_LOGFF(...) android_debugff( __func__, __FILE__, __VA_ARGS__ )
#define XP_GID_LOGFF( GID, ... ) \
android_gid_debugff( (GID), __func__, __FILE__, __VA_ARGS__ )
#define XP_WARNF(...) android_debugf( __VA_ARGS__ )
#else
#define XP_DEBUGF(...)
#define XP_LOGF(...)
#define XP_LOGFF(...)
#define XP_GID_LOGFF( GID, FMT, ... )
#define XP_WARNF(...)
#endif

View file

@ -205,12 +205,12 @@ struct RematchInfo {
# define dupe_timerRunning() server_canPause(server)
#ifdef DEBUG
# define SRVR_LOGFF( FMT, ... ) { \
# define SRVR_LOGFF( ... ) { \
XP_U32 gameID = server->vol.gi->gameID; \
XP_GID_LOGFF( gameID, FMT, ##__VA_ARGS__ ); \
XP_GID_LOGFF( gameID, __VA_ARGS__ ); \
}
#else
# define SRVR_LOGFF( FMT, ... )
# define SRVR_LOGFF( ... )
#endif