This allows actually honoring the requested log level properly if there are multiple codec instances within the same process.
Unified · Split
| @@ -44,13 +44,15 @@ class welsCodecTrace { · 43 unmodified lines | ||
| 44 | 44 | welsCodecTrace(); |
| 45 | 45 | ~welsCodecTrace(); |
| 46 | 46 | |
| 47 | − static void CODEC_TRACE (void* pIgnore, const int32_t kiLevel, const char* kpStrFormat, va_list vl); | |
| 48 | − | |
| 49 | 47 | void SetTraceLevel (const int32_t kiLevel); |
| 50 | 48 | |
| 49 | + private: | |
| 50 | + static void StaticCodecTrace (void* pCtx, const int32_t kiLevel, const char* kpStrFormat, va_list vl); | |
| 51 | + void CodecTrace (const int32_t kiLevel, const char* kpStrFormat, va_list vl); | |
| 52 | + | |
| 53 | + int32_t m_iTraceLevel; | |
| 54 | + CM_WELS_TRACE m_fpTrace; | |
| 51 | 55 | public: |
| 52 | − static int32_t m_iTraceLevel; | |
| 53 | − static CM_WELS_TRACE m_fpTrace; | |
| 54 | 56 | |
| 55 | 57 | SLogContext m_sLogCtx; |
| 56 | 58 | }; |
| @@ -46,15 +46,14 @@ · 45 unmodified lines | ||
| 46 | 46 | |
| 47 | 47 | #include "logging.h" |
| 48 | 48 | |
| 49 | −int32_t welsCodecTrace::m_iTraceLevel = WELS_LOG_DEFAULT; | |
| 50 | −CM_WELS_TRACE welsCodecTrace::m_fpTrace = NULL; | |
| 51 | 49 | |
| 52 | 50 | welsCodecTrace::welsCodecTrace() { |
| 53 | 51 | |
| 52 | + m_iTraceLevel = WELS_LOG_DEFAULT; | |
| 54 | 53 | m_fpTrace = welsStderrTrace; |
| 55 | 54 | |
| 56 | 55 | m_sLogCtx.pLogCtx = this; |
| 57 | − m_sLogCtx.pfLog = CODEC_TRACE; | |
| 56 | + m_sLogCtx.pfLog = StaticCodecTrace; | |
| 58 | 57 | } |
| 59 | 58 | |
| 60 | 59 | welsCodecTrace::~welsCodecTrace() { |
| @@ -63,7 +62,12 @@ welsCodecTrace::~welsCodecTrace() { · 2 unmodified lines | ||
| 63 | 62 | |
| 64 | 63 | #define MAX_LOG_SIZE 1024 |
| 65 | 64 | |
| 66 | −void welsCodecTrace::CODEC_TRACE (void* ignore, const int32_t iLevel, const char* Str_Format, va_list vl) { | |
| 65 | +void welsCodecTrace::StaticCodecTrace (void* pCtx, const int32_t iLevel, const char* Str_Format, va_list vl) { | |
| 66 | + welsCodecTrace* self = (welsCodecTrace*) pCtx; | |
| 67 | + self->CodecTrace (iLevel, Str_Format, vl); | |
| 68 | +} | |
| 69 | + | |
| 70 | +void welsCodecTrace::CodecTrace (const int32_t iLevel, const char* Str_Format, va_list vl) { | |
| 67 | 71 | if (m_iTraceLevel < iLevel) { |
| 68 | 72 | return; |
| 69 | 73 | } |