all repos — mgba @ 5c81fc76d26a001f2b06945e17cbc1981d5bc0c1

mGBA Game Boy Advance Emulator

Core: Create mThreadLogger
Jeffrey Pfau jeffrey@endrift.com
Mon, 08 Feb 2016 05:26:13 -0800
commit

5c81fc76d26a001f2b06945e17cbc1981d5bc0c1

parent

b619ebf965ce430f6e20b65433cdbfdbe5f16ce2

3 files changed, 15 insertions(+), 6 deletions(-)

jump to
M src/core/log.hsrc/core/log.h

@@ -15,7 +15,9 @@ mLOG_WARN = 0x04,

mLOG_INFO = 0x08, mLOG_DEBUG = 0x10, mLOG_STUB = 0x20, - mLOG_GAME_ERROR = 0x40 + mLOG_GAME_ERROR = 0x40, + + mLOG_ALL = 0x7F }; struct mLogger {
M src/core/thread.csrc/core/thread.c

@@ -142,6 +142,7 @@ }

bool mCoreThreadStart(struct mCoreThread* threadContext) { threadContext->state = THREAD_INITIALIZED; + threadContext->logger.p = threadContext; MutexInit(&threadContext->stateMutex); ConditionInit(&threadContext->stateCond);

@@ -380,19 +381,19 @@ }

#endif static void _mCoreLog(struct mLogger* logger, int category, enum mLogLevel level, const char* format, va_list args) { + UNUSED(logger); printf("%s: ", mLogCategoryName(category)); vprintf(format, args); printf("\n"); - } struct mLogger* mCoreThreadLogger(void) { struct mCoreThread* thread = mCoreThreadGet(); if (thread) { - if (!thread->logger.log) { - thread->logger.log = _mCoreLog; + if (!thread->logger.d.log) { + thread->logger.d.log = _mCoreLog; } - return &thread->logger; + return &thread->logger.d; } return NULL; }
M src/core/thread.hsrc/core/thread.h

@@ -31,6 +31,12 @@ THREAD_SHUTDOWN,

THREAD_CRASHED }; +struct mCoreThread; +struct mThreadLogger { + struct mLogger d; + struct mCoreThread* p; +}; + struct mCoreThread { // Input struct mCore* core;

@@ -45,7 +51,7 @@ enum mCoreThreadState savedState;

int interruptDepth; bool frameWasOn; - struct mLogger logger; + struct mThreadLogger logger; enum mLogLevel logLevel; ThreadCallback startCallback; ThreadCallback cleanCallback;