shithub: openh264

Download patch

ref: 74b52e8a31c47b6fc10394b7371c8aec6c397d42
parent: 396249fedc07ce1a7191c1faee83ffaf96e488db
parent: ef7cce3d148e206f2b34f967cee1b545bc08127d
author: dongzha <[email protected]>
date: Thu Jul 17 06:43:14 EDT 2014

Merge pull request #1183 from ruil2/trace_tag

    add trace tag

--- a/codec/common/inc/utils.h
+++ b/codec/common/inc/utils.h
@@ -42,7 +42,7 @@
 #include <stdarg.h>
 #include "typedefs.h"
 
-
+#define MAX_LOG_SIZE	1024
 /*
  *	Function pointer declaration for various tool sets
  */
@@ -56,7 +56,8 @@
 
 
 #ifdef __GNUC__
-extern void WelsLog (SLogContext* pCtx, int32_t iLevel, const char* kpFmt, ...) __attribute__ ((__format__ (__printf__, 3,
+extern void WelsLog (SLogContext* pCtx, int32_t iLevel, const char* kpFmt, ...) __attribute__ ((__format__ (__printf__,
+    3,
     4)));
 #else
 extern void WelsLog (SLogContext* pCtx, int32_t iLevel, const char* kpFmt, ...);
--- a/codec/common/src/utils.cpp
+++ b/codec/common/src/utils.cpp
@@ -39,7 +39,7 @@
  */
 #include "utils.h"
 #include "crt_util_safe_x.h"	// Safe CRT routines like utils for cross platforms
-
+#include "codec_app_def.h"
 float WelsCalcPsnr (const void* kpTarPic,
                     const int32_t kiTarStride,
                     const void* kpRefPic,
@@ -50,8 +50,27 @@
 
 void WelsLog (SLogContext* logCtx, int32_t iLevel, const char* kpFmt, ...) {
   va_list vl;
+  char pTraceTag[MAX_LOG_SIZE];
+  switch (iLevel) {
+  case WELS_LOG_ERROR:
+    WelsSnprintf (pTraceTag, MAX_LOG_SIZE, "[OpenH264] Error:");
+    break;
+  case WELS_LOG_WARNING:
+    WelsSnprintf (pTraceTag, MAX_LOG_SIZE, "[OpenH264] Warning:");
+    break;
+  case WELS_LOG_INFO:
+    WelsSnprintf (pTraceTag, MAX_LOG_SIZE, "[OpenH264] Info:");
+    break;
+  case WELS_LOG_DEBUG:
+    WelsSnprintf (pTraceTag, MAX_LOG_SIZE, "[OpenH264] Debug:");
+    break;
+  default:
+    WelsSnprintf (pTraceTag, MAX_LOG_SIZE, "[OpenH264] Detail:");
+    break;
+  }
+  WelsStrcat(pTraceTag,MAX_LOG_SIZE,kpFmt);
   va_start (vl, kpFmt);
-  logCtx->pfLog (logCtx->pLogCtx, iLevel, kpFmt, vl);
+  logCtx->pfLog (logCtx->pLogCtx, iLevel, pTraceTag, vl);
   va_end (vl);
 }
 
--- a/codec/common/src/welsCodecTrace.cpp
+++ b/codec/common/src/welsCodecTrace.cpp
@@ -64,7 +64,7 @@
   m_fpTrace = NULL;
 }
 
-#define MAX_LOG_SIZE	1024
+
 
 void welsCodecTrace::StaticCodecTrace (void* pCtx, const int32_t iLevel, const char* Str_Format, va_list vl) {
   welsCodecTrace* self = (welsCodecTrace*) pCtx;