Don't use global variables in welsCodecTrace
This allows actually honoring the requested log level properly if there are multiple codec instances within the same process.
This commit is contained in:
parent
cb5ee6c239
commit
ce8065fe68
@ -44,13 +44,15 @@ class welsCodecTrace {
|
||||
welsCodecTrace();
|
||||
~welsCodecTrace();
|
||||
|
||||
static void CODEC_TRACE (void* pIgnore, const int32_t kiLevel, const char* kpStrFormat, va_list vl);
|
||||
|
||||
void SetTraceLevel (const int32_t kiLevel);
|
||||
|
||||
private:
|
||||
static void StaticCodecTrace (void* pCtx, const int32_t kiLevel, const char* kpStrFormat, va_list vl);
|
||||
void CodecTrace (const int32_t kiLevel, const char* kpStrFormat, va_list vl);
|
||||
|
||||
int32_t m_iTraceLevel;
|
||||
CM_WELS_TRACE m_fpTrace;
|
||||
public:
|
||||
static int32_t m_iTraceLevel;
|
||||
static CM_WELS_TRACE m_fpTrace;
|
||||
|
||||
SLogContext m_sLogCtx;
|
||||
};
|
||||
|
@ -46,15 +46,14 @@
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
int32_t welsCodecTrace::m_iTraceLevel = WELS_LOG_DEFAULT;
|
||||
CM_WELS_TRACE welsCodecTrace::m_fpTrace = NULL;
|
||||
|
||||
welsCodecTrace::welsCodecTrace() {
|
||||
|
||||
m_iTraceLevel = WELS_LOG_DEFAULT;
|
||||
m_fpTrace = welsStderrTrace;
|
||||
|
||||
m_sLogCtx.pLogCtx = this;
|
||||
m_sLogCtx.pfLog = CODEC_TRACE;
|
||||
m_sLogCtx.pfLog = StaticCodecTrace;
|
||||
}
|
||||
|
||||
welsCodecTrace::~welsCodecTrace() {
|
||||
@ -63,7 +62,12 @@ welsCodecTrace::~welsCodecTrace() {
|
||||
|
||||
#define MAX_LOG_SIZE 1024
|
||||
|
||||
void welsCodecTrace::CODEC_TRACE (void* ignore, const int32_t iLevel, const char* Str_Format, va_list vl) {
|
||||
void welsCodecTrace::StaticCodecTrace (void* pCtx, const int32_t iLevel, const char* Str_Format, va_list vl) {
|
||||
welsCodecTrace* self = (welsCodecTrace*) pCtx;
|
||||
self->CodecTrace (iLevel, Str_Format, vl);
|
||||
}
|
||||
|
||||
void welsCodecTrace::CodecTrace (const int32_t iLevel, const char* Str_Format, va_list vl) {
|
||||
if (m_iTraceLevel < iLevel) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user