cleanup the logging a bit.
authorJim Carroll <thecarrolls@jiminger.com>
Mon, 17 Sep 2012 00:41:18 +0000 (20:41 -0400)
committerJim Carroll <thecarrolls@jiminger.com>
Mon, 17 Sep 2012 01:15:22 +0000 (21:15 -0400)
xbmc/interfaces/legacy/AddonClass.cpp
xbmc/interfaces/legacy/AddonClass.h
xbmc/interfaces/legacy/AddonUtils.cpp
xbmc/interfaces/legacy/AddonUtils.h
xbmc/interfaces/legacy/CallbackHandler.cpp

index fe214ed..eda9a04 100644 (file)
@@ -26,6 +26,8 @@
 #include "LanguageHook.h"
 #include "AddonUtils.h"
 
+using namespace XBMCAddonUtils;
+
 namespace XBMCAddon
 {
   // need a place to put the vtab
@@ -36,8 +38,9 @@ namespace XBMCAddon
     if (languageHook != NULL)
       languageHook->Release();
 
-#ifdef LOG_LIFECYCLE_EVENTS
-    CLog::Log(LOGDEBUG, "NEWADDON LIFECYCLE destroying %s 0x%lx", classname.c_str(), (long)(((void*)this)));
+#ifdef ENABLE_TRACE_API
+    TraceGuard tg_;
+    CLog::Log(LOGDEBUG, "%sNEWADDON destroying %s 0x%lx", tg_.getSpaces(), classname.c_str(), (long)(((void*)this)));
 #endif
 
 #ifdef XBMC_ADDON_DEBUG_MEMORY
@@ -48,8 +51,9 @@ namespace XBMCAddon
   AddonClass::AddonClass(const char* cname) : refs(0L), classname(cname), m_isDeallocating(false), 
                                               languageHook(NULL)
   {
-#ifdef LOG_LIFECYCLE_EVENTS
-    CLog::Log(LOGDEBUG, "NEWADDON LIFECYCLE constructing %s 0x%lx", classname.c_str(), (long)(((void*)this)));
+#ifdef ENABLE_TRACE_API
+    TraceGuard tg_;
+    CLog::Log(LOGDEBUG, "%sNEWADDON constructing %s 0x%lx", tg_.getSpaces(), classname.c_str(), (long)(((void*)this)));
 #endif
 
 #ifdef XBMC_ADDON_DEBUG_MEMORY
index d23e795..d9e991c 100644 (file)
@@ -28,7 +28,7 @@
  *
  * Comment out (or uncomment out) to change the setting.
  */
-#define LOG_LIFECYCLE_EVENTS
+//#define LOG_LIFECYCLE_EVENTS
 
 /** 
  * Defining XBMC_ADDON_DEBUG_MEMORY will make the Acquire and Release
index 6f5bdaf..6bc03d8 100644 (file)
@@ -92,6 +92,8 @@ namespace XBMCAddonUtils
 
   static char** spaces = getSpacesArray(256);
 
+  const char* TraceGuard::getSpaces() { return spaces[depth]; }
+
   TraceGuard::TraceGuard(const char* _function) :function(_function) 
   {
     parent = tlParent.get();
@@ -102,9 +104,18 @@ namespace XBMCAddonUtils
     CLog::Log(LOGDEBUG, "%sNEWADDON Entering %s", spaces[depth], function); 
   }
 
+  TraceGuard::TraceGuard() :function(NULL) 
+  {
+    parent = tlParent.get();
+    depth = parent == NULL ? 0 : parent->depth + 1;
+    tlParent.set(this);
+    // silent
+  }
+
   TraceGuard::~TraceGuard() 
   {
-    CLog::Log(LOGDEBUG, "%sNEWADDON Leaving %s", spaces[depth], function);
+    if (function)
+      CLog::Log(LOGDEBUG, "%sNEWADDON Leaving %s", spaces[depth], function);
 
     // need to pop the stack
     tlParent.set(this->parent);
index 0a48630..bb0e747 100644 (file)
@@ -28,7 +28,7 @@
 
 #pragma once
 
-#define ENABLE_TRACE_API
+//#define ENABLE_TRACE_API
 
 #include "threads/SingleLock.h"
 
@@ -92,7 +92,10 @@ namespace XBMCAddonUtils
     TraceGuard* parent;
     int depth;
 
+    const char* getSpaces();
+
     TraceGuard(const char* _function);
+    TraceGuard();
     ~TraceGuard();
   };
 #endif
index ec40b85..38b4388 100644 (file)
@@ -101,7 +101,9 @@ namespace XBMCAddon
           // we need to grab the object lock to see if the object of the call 
           //  is deallocating. holding this lock should prevent it from 
           //  deallocating durring the execution of this call.
-          CLog::Log(LOGDEBUG,"NEWADDON executing callback 0x%lx", (long)(p->cb.get()));
+#ifdef ENABLE_TRACE_API
+          CLog::Log(LOGDEBUG,"%sNEWADDON executing callback 0x%lx",_tg.getSpaces(),(long)(p->cb.get()));
+#endif
           Synchronize lock2(*(p->cb->getObject()));
           if (!p->cb->getObject()->isDeallocating())
           {
@@ -140,7 +142,9 @@ namespace XBMCAddon
 
       if(p->handler->shouldRemoveCallback(userData))
       {
-        CLog::Log(LOGDEBUG,"NEWADDON removing callback 0x%lx for PyThreadState 0x%lx from queue", (long)(p->cb.get()) ,(long)userData);
+#ifdef ENABLE_TRACE_API
+        CLog::Log(LOGDEBUG,"%sNEWADDON removing callback 0x%lx for PyThreadState 0x%lx from queue", _tg.getSpaces(),(long)(p->cb.get()) ,(long)userData);
+#endif
         g_callQueue.erase(iter);
       }
       else