History

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.

Martin Storsjö committed 12 years ago

Commit ce8065f1 parent cb5ee6c2 files · +14 −8Browse files

Unified · Split

2 files
  1. codec/common/inc/welsCodecTrace.h +6 −4
  2. codec/common/src/welsCodecTrace.cpp +8 −4
codec/common/inc/welsCodecTrace.h+6−4
@@ -44,13 +44,15 @@ class welsCodecTrace { · 43 unmodified lines
44 welsCodecTrace();44 welsCodecTrace();
45 ~welsCodecTrace();45 ~welsCodecTrace();
46 46
47 static void CODEC_TRACE (void* pIgnore, const int32_t kiLevel, const char* kpStrFormat, va_list vl);
48
49 void SetTraceLevel (const int32_t kiLevel);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 public:55 public:
52 static int32_t m_iTraceLevel;
53 static CM_WELS_TRACE m_fpTrace;
54 56
55 SLogContext m_sLogCtx;57 SLogContext m_sLogCtx;
56};58};
codec/common/src/welsCodecTrace.cpp+8−4
@@ -46,15 +46,14 @@ · 45 unmodified lines
46 46
47#include "logging.h"47#include "logging.h"
48 48
49int32_t welsCodecTrace::m_iTraceLevel = WELS_LOG_DEFAULT;
50CM_WELS_TRACE welsCodecTrace::m_fpTrace = NULL;
51 49
52welsCodecTrace::welsCodecTrace() {50welsCodecTrace::welsCodecTrace() {
53 51
52 m_iTraceLevel = WELS_LOG_DEFAULT;
54 m_fpTrace = welsStderrTrace;53 m_fpTrace = welsStderrTrace;
55 54
56 m_sLogCtx.pLogCtx = this;55 m_sLogCtx.pLogCtx = this;
57 m_sLogCtx.pfLog = CODEC_TRACE;56 m_sLogCtx.pfLog = StaticCodecTrace;
58}57}
59 58
60welsCodecTrace::~welsCodecTrace() {59welsCodecTrace::~welsCodecTrace() {
@@ -63,7 +62,12 @@ welsCodecTrace::~welsCodecTrace() { · 2 unmodified lines
63 62
64#define MAX_LOG_SIZE 102463#define MAX_LOG_SIZE 1024
65 64
66void welsCodecTrace::CODEC_TRACE (void* ignore, const int32_t iLevel, const char* Str_Format, va_list vl) {65void 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
70void welsCodecTrace::CodecTrace (const int32_t iLevel, const char* Str_Format, va_list vl) {
67 if (m_iTraceLevel < iLevel) {71 if (m_iTraceLevel < iLevel) {
68 return;72 return;
69 }73 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t