Core: Create mThreadLogger
Jeffrey Pfau jeffrey@endrift.com
Mon, 08 Feb 2016 05:26:13 -0800
3 files changed,
15 insertions(+),
6 deletions(-)
M
src/core/log.h
→
src/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.c
→
src/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.h
→
src/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;