diff --git a/src/gba/gba.c b/src/gba/gba.c index a599d5196..60c5a0527 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -607,13 +607,17 @@ void GBAHalt(struct GBA* gba) { static void _GBAVLog(struct GBA* gba, enum GBALogLevel level, const char* format, va_list args) { struct GBAThread* threadContext = GBAThreadGetContext(); - if (threadContext) { - if (!gba) { - gba = threadContext->gba; - } + enum GBALogLevel logLevel = -1; + + if (gba) { + logLevel = gba->logLevel; } - if (gba && !(level & gba->logLevel) && level != GBA_LOG_FATAL) { + if (threadContext) { + logLevel = threadContext->logLevel; + } + + if (!(level & logLevel) && level != GBA_LOG_FATAL) { return; }