diff --git a/src/gba/gba.c b/src/gba/gba.c index 0724e36c6..bb18400bb 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -547,10 +547,10 @@ static void _GBAVLog(struct GBA* gba, enum GBALogLevel level, const char* format threadContext->state = THREAD_CRASHED; MutexUnlock(&threadContext->stateMutex); } - if (threadContext->logHandler) { - threadContext->logHandler(threadContext, level, format, args); - return; - } + } + if (gba->logHandler) { + gba->logHandler(threadContext, level, format, args); + return; } vprintf(format, args); diff --git a/src/gba/gba.h b/src/gba/gba.h index 630530ff8..4c67a662c 100644 --- a/src/gba/gba.h +++ b/src/gba/gba.h @@ -90,9 +90,12 @@ enum { struct GBA; struct GBARotationSource; +struct GBAThread; struct Patch; struct VFile; +typedef void (*GBALogHandler)(struct GBAThread*, enum GBALogLevel, const char* format, va_list args); + struct GBATimer { uint16_t reload; uint16_t oldReload; @@ -141,7 +144,8 @@ struct GBA { const char* activeFile; - int logLevel; + GBALogHandler logHandler; + enum GBALogLevel logLevel; enum GBAIdleLoopOptimization idleOptimization; uint32_t idleLoop; diff --git a/src/gba/supervisor/thread.c b/src/gba/supervisor/thread.c index a8eb1bc09..ae08c440d 100644 --- a/src/gba/supervisor/thread.c +++ b/src/gba/supervisor/thread.c @@ -134,6 +134,7 @@ static THREAD_ENTRY _GBAThreadRun(void* context) { gba.sync = &threadContext->sync; threadContext->gba = &gba; gba.logLevel = threadContext->logLevel; + gba.logHandler = threadContext->logHandler; gba.idleOptimization = threadContext->idleOptimization; #ifdef USE_PTHREADS pthread_setspecific(_contextKey, threadContext); diff --git a/src/gba/supervisor/thread.h b/src/gba/supervisor/thread.h index 11b435d26..a39c52a4e 100644 --- a/src/gba/supervisor/thread.h +++ b/src/gba/supervisor/thread.h @@ -20,7 +20,6 @@ struct GBACheatSet; struct GBAOptions; typedef void (*ThreadCallback)(struct GBAThread* threadContext); -typedef void (*LogHandler)(struct GBAThread*, enum GBALogLevel, const char* format, va_list args); enum ThreadState { THREAD_INITIALIZED = -1, @@ -95,7 +94,7 @@ struct GBAThread { enum ThreadState savedState; int interruptDepth; - LogHandler logHandler; + GBALogHandler logHandler; int logLevel; ThreadCallback startCallback; ThreadCallback cleanCallback;