]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Unity/X11: Make annoying logs opt-in.
authorVMware, Inc <>
Tue, 28 Jun 2011 19:53:49 +0000 (12:53 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Tue, 28 Jun 2011 19:53:49 +0000 (12:53 -0700)
Noisy logging isn't just annoying.  By drowning out useful stuff and
slowing things down, it's harmful.  From now on, users can opt in to
annoying Unity logging by setting the VMWARE_UNITY_VERBOSE_LOGGING
environment variable before running vmusr.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/services/plugins/unity/unitylib/unityPlatformX11.cc
open-vm-tools/services/plugins/unity/unitylib/unityPlatformX11Window.cc
open-vm-tools/services/plugins/unity/unitylib/unityX11.h

index ceea43bba3d86fe4b53398953274b433aa7959d7..992a2bb1433a8ec0da0adf81f86808b25416d139 100644 (file)
@@ -177,6 +177,7 @@ UnityPlatformInit(UnityWindowTracker *tracker,                            // IN
    Debug("UnityPlatformInit: Running\n");
 
    up = (UnityPlatform*)Util_SafeCalloc(1, sizeof *up);
+   up->noisyLogging = getenv("VMWARE_UNITY_VERBOSE_LOGGING") ? TRUE : FALSE;
    up->tracker = tracker;
    up->hostCallbacks = hostCallbacks;
 
index 1d02e3b2e03e289d5fb8b6e6dcfd9ba664b69189..43afd1f542970d7c8a12acbe4e1bcd10da8e05fa 100644 (file)
@@ -190,8 +190,8 @@ CompareStackingOrder(UnityPlatform *up,         // IN
     */
    if (numURelevant != numXRelevant ||
        numURelevant != up->tracker->count) {
-      Debug("%s: mismatch (count): server %u, unity %u, uwt %u\n", __func__,
-            numXRelevant, numURelevant, up->tracker->count);
+      UNITY_DEBUGLOG(up, "%s: mismatch (count): server %u, unity %u, uwt %u\n", __func__,
+                     numXRelevant, numURelevant, up->tracker->count);
       goto out;
    }
 
@@ -232,22 +232,22 @@ CompareStackingOrder(UnityPlatform *up,         // IN
 
       if (memcmp(relevantXChildren, relevantUChildren, childrenSize) ||
           memcmp(relevantXChildren, trackerChildren, childrenSize)) {
-         Debug("%s: mismatch!\n", callerName);
-         Debug("%s: %8s %10s %10s %10s\n", callerName, "index", "X Server",
-               "Unity", "UWT");
+         UNITY_DEBUGLOG(up, "%s: mismatch!\n", callerName);
+         UNITY_DEBUGLOG(up, "%s: %8s %10s %10s %10s\n", callerName, "index", "X Server",
+                        "Unity", "UWT");
 
          for (i = 0; i < nWindows; i++) {
             if (relevantXChildren[i] != relevantUChildren[i] ||
                 relevantXChildren[i] != trackerChildren[i]) {
-               Debug("%s: [%6u] %#10lx %#10lx %#10lx\n", callerName, i,
-                     relevantXChildren[i], relevantUChildren[i],
-                     trackerChildren[i]);
+               UNITY_DEBUGLOG(up, "%s: [%6u] %#10lx %#10lx %#10lx\n", callerName, i,
+                              relevantXChildren[i], relevantUChildren[i],
+                              trackerChildren[i]);
             }
          }
       } else {
-         Debug("%s: match (%u windows).\n", callerName, nWindows);
+         UNITY_DEBUGLOG(up, "%s: match (%u windows).\n", callerName, nWindows);
          for (i = 0; i < nWindows; i++) {
-            Debug("%s:   [%u] %#lx\n", callerName, i, relevantXChildren[i]);
+            UNITY_DEBUGLOG(up, "%s:   [%u] %#lx\n", callerName, i, relevantXChildren[i]);
          }
       }
    }
@@ -450,8 +450,8 @@ UPWindowSetWindows(UnityPlatform *up,        // IN
 
    wasRelevant = upw->isRelevant;
 
-   Debug("%s: %#lx::%#lx -> %#lx::%#lx\n", __func__, upw->toplevelWindow,
-         upw->clientWindow, toplevelWindow, clientWindow);
+   UNITY_DEBUGLOG(up, "%s: %#lx::%#lx -> %#lx::%#lx\n", __func__, upw->toplevelWindow,
+                  upw->clientWindow, toplevelWindow, clientWindow);
    UPWindowSetRelevance(up, upw, FALSE);
    if (upw->toplevelWindow) {
       XSelectInput(up->display, upw->toplevelWindow, 0);
@@ -561,8 +561,8 @@ UPWindow_Create(UnityPlatform *up,     // IN
    if (HashTable_Lookup(up->allWindows,
                         GUINT_TO_POINTER(toplevelWindow),
                         (void **)&upw)) {
-      Debug("Lookup of window %#lx returned %#lx\n",
-            toplevelWindow, upw->toplevelWindow);
+      Log("Lookup of window %#lx returned %#lx\n",
+          toplevelWindow, upw->toplevelWindow);
       abort();
    }
 
@@ -577,8 +577,8 @@ UPWindow_Create(UnityPlatform *up,     // IN
    upw = (UnityPlatformWindow*)Util_SafeCalloc(1, sizeof *upw);
    upw->refs = 1;
 
-   Debug("Creating new window for %#lx/%#lx/%#lx\n",
-         toplevelWindow, clientWindow, rootWindow);
+   UNITY_DEBUGLOG(up, "Creating new window for %#lx/%#lx/%#lx\n",
+                  toplevelWindow, clientWindow, rootWindow);
    upw->rootWindow = rootWindow;
    for (upw->screenNumber = 0;
         upw->screenNumber < (int)up->rootWindows->numWindows
@@ -953,7 +953,7 @@ UPWindow_Restack(UnityPlatform *up,        // IN
       ASSERT(upw->lowerWindow != upw);
       if (upw->isRelevant) {
          up->stackingChanged = TRUE;
-         Debug("Stacking order has changed\n");
+         UNITY_DEBUGLOG(up, "Stacking order has changed\n");
       }
    }
 }
@@ -1370,9 +1370,10 @@ UPWindow_CheckRelevance(UnityPlatform *up,        // IN
 out:
    ASSERT(shouldBeRelevant >= 0);
 
-   Debug("Relevance for (%p) %#lx/%#lx/%#lx is %d (window type %d)\n",
-         upw, upw->toplevelWindow, upw->clientWindow, upw->rootWindow,
-         shouldBeRelevant, upw->windowType);
+   UNITY_DEBUGLOG(up,
+      "Relevance for (%p) %#lx/%#lx/%#lx is %d (window type %d)\n",
+      upw, upw->toplevelWindow, upw->clientWindow, upw->rootWindow,
+      shouldBeRelevant, upw->windowType);
 
    UPWindowSetRelevance(up, upw, shouldBeRelevant ? TRUE : FALSE);
 }
@@ -2200,9 +2201,9 @@ UPWindowProcessConfigureEvent(UnityPlatform *up,        // IN
       y -= border_width;
 
 #ifdef VMX86_DEVEL
-      Debug("Moving window %#lx/%#lx to (%d, %d) +(%d, %d)\n",
-            upw->toplevelWindow, upw->clientWindow,
-            x, y, xprime - x, yprime - y);
+      UNITY_DEBUGLOG(up, "Moving window %#lx/%#lx to (%d, %d) +(%d, %d)\n",
+                     upw->toplevelWindow, upw->clientWindow,
+                     x, y, xprime - x, yprime - y);
 #endif
 
       /*
@@ -2224,13 +2225,14 @@ UPWindowProcessConfigureEvent(UnityPlatform *up,        // IN
          || (xevent->xconfigure.above == None && upw->lowerWindow)
          || (upw->lowerWindow && xevent->xconfigure.above
               != upw->lowerWindow->toplevelWindow)) {
-         Debug("Marking window %#lx/%#lx for restacking\n",
-               upw->toplevelWindow, upw->clientWindow);
+         UNITY_DEBUGLOG(up, "Marking window %#lx/%#lx for restacking\n",
+                        upw->toplevelWindow, upw->clientWindow);
          UPWindow_Restack(up, upw, xevent->xconfigure.above);
       }
    } else {
-      Debug("ProcessConfigureEvent skipped event on window %#lx (upw was %#lx/%#lx)\n",
-            xevent->xconfigure.window, upw->toplevelWindow, upw->clientWindow);
+      UNITY_DEBUGLOG(up,
+         "ProcessConfigureEvent skipped event on window %#lx (upw was %#lx/%#lx)\n",
+         xevent->xconfigure.window, upw->toplevelWindow, upw->clientWindow);
    }
 
 #ifdef VMX86_DEVEL
@@ -2957,7 +2959,8 @@ UPWindowUpdateDesktop(UnityPlatform *up,        // IN
          desktopId = up->desktopInfo.guestDesktopToUnity[guestDesktop];
       }
 
-      Debug("Window %#lx is now on desktop %d\n", upw->toplevelWindow, desktopId);
+      UNITY_DEBUGLOG(up, "Window %#lx is now on desktop %d\n", upw->toplevelWindow,
+                     desktopId);
       UnityWindowTracker_ChangeWindowDesktop(up->tracker,
                                              upw->toplevelWindow,
                                              desktopId);
@@ -3237,20 +3240,22 @@ UPWindowUpdateState(UnityPlatform *up,            // IN
          if (cDesk == gDesk || gDesk == -1) {
             if (isMinimized) {
                if (! (newState & UNITY_WINDOW_STATE_MINIMIZED)) {
-                  Debug("Enabling minimized attribute for window %#lx/%#lx\n",
-                        upw->toplevelWindow, upw->clientWindow);
+                  UNITY_DEBUGLOG(up,
+                     "Enabling minimized attribute for window %#lx/%#lx\n",
+                     upw->toplevelWindow, upw->clientWindow);
                   newState |= UNITY_WINDOW_STATE_MINIMIZED;
                }
             } else {
                if ((newState & UNITY_WINDOW_STATE_MINIMIZED)) {
-                  Debug("Disabling minimized attribute for window %#lx/%#lx\n",
-                        upw->toplevelWindow, upw->clientWindow);
+                  UNITY_DEBUGLOG(up,
+                     "Disabling minimized attribute for window %#lx/%#lx\n",
+                     upw->toplevelWindow, upw->clientWindow);
                   newState &= ~UNITY_WINDOW_STATE_MINIMIZED;
                }
             }
          }
       } else {
-         Debug("%s: Unable to get window desktop\n", __FUNCTION__);
+         Log("%s: Unable to get window desktop\n", __FUNCTION__);
       }
 
       if (newState != info->state) {
@@ -3523,12 +3528,12 @@ UnityPlatformMinimizeWindow(UnityPlatform *up,    // IN
       return FALSE;
    }
 
-   Debug("UnityPlatformMinimizeWindow(%#lx)\n", upw->toplevelWindow);
+   UNITY_DEBUGLOG(up, "UnityPlatformMinimizeWindow(%#lx)\n", upw->toplevelWindow);
    upw->wantInputFocus = FALSE;
    if (!upw->isMinimized) {
       Atom data[5] = {0, 0, 0, 0, 0};
 
-      Debug("Minimizing window %#x\n", window);
+      UNITY_DEBUGLOG(up, "Minimizing window %#x\n", window);
       upw->isMinimized = TRUE;
       data[0] = _NET_WM_STATE_ADD;
       if (UnityPlatformWMProtocolSupported(up, UNITY_X11_WM__NET_WM_STATE_MINIMIZED)) {
@@ -3542,7 +3547,7 @@ UnityPlatformMinimizeWindow(UnityPlatform *up,    // IN
 
       XIconifyWindow(up->display, upw->clientWindow, 0);
    } else {
-      Debug("Window %#x is already minimized\n", window);
+      UNITY_DEBUGLOG(up, "Window %#x is already minimized\n", window);
    }
 
 
index fb5c76ed4b3d9f05c0ac76c550ccae3b1859e346..05b86879b49d10690c7caaadd64fbe47415de2f7 100644 (file)
@@ -324,8 +324,20 @@ struct _UnityPlatform {
    int shapeErrorBase;
 
    vmware::tools::unity::WindowPathFactory* wpFactory;
+
+   /* See UNITY_ANNOY(). */
+   Bool noisyLogging;
 };
 
+
+#define UNITY_DEBUGLOG(unityPlatform, ...)      do {                    \
+   if (   LIKELY(unityPlatform)                                         \
+       && UNLIKELY(unityPlatform->noisyLogging)) {                      \
+          Debug(__VA_ARGS__);                                           \
+   }                                                                    \
+} while(0)
+
+
 /*
  * Holds per-window platform-specific data.
  */