Better logging -- less repeated information.


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@575 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/x0vncserver/Image.cxx b/x0vncserver/Image.cxx
index 24d6c37..fc66c5a 100644
--- a/x0vncserver/Image.cxx
+++ b/x0vncserver/Image.cxx
@@ -512,14 +512,12 @@
     if (mayUseShm) {
       image = new IrixOverlayShmImage(d, width, height);
       if (image->xim != NULL) {
-        vlog.info("Using IRIX overlay image with SHM support");
         return image;
       }
     }
 #elif defined(HAVE_SUN_OVL)
     image = new SolarisOverlayImage(d, width, height);
     if (image->xim != NULL) {
-      vlog.info("Using Solaris overlay image");
       return image;
     }
 #endif
@@ -536,7 +534,6 @@
   if (mayUseShm) {
     image = new ShmImage(d, width, height);
     if (image->xim != NULL) {
-      vlog.info("Using shared memory image");
       return image;
     }
 
@@ -547,7 +544,6 @@
 
   // Fall back to Xlib image.
 
-  vlog.info("Using Xlib-based image");
   image = new Image(d, width, height);
   return image;
 }
diff --git a/x0vncserver/Image.h b/x0vncserver/Image.h
index e3de17d..535cee6 100644
--- a/x0vncserver/Image.h
+++ b/x0vncserver/Image.h
@@ -38,7 +38,14 @@
   Image(Display *d, int width, int height);
   virtual ~Image();
 
-  bool isTrueColor() { return trueColor; }
+  bool isTrueColor() const { return trueColor; }
+
+  virtual const char *className() const {
+    return "Image";
+  }
+  virtual const char *classDesc() const {
+    return "basic Xlib image";
+  }
 
   virtual void get(Window wnd, int x = 0, int y = 0);
   virtual void get(Window wnd, int x, int y, int w, int h);
@@ -89,6 +96,13 @@
   ShmImage(Display *d, int width, int height);
   virtual ~ShmImage();
 
+  virtual const char *className() const {
+    return "ShmImage";
+  }
+  virtual const char *classDesc() const {
+    return "shared memory image";
+  }
+
   virtual void get(Window wnd, int x = 0, int y = 0);
   virtual void get(Window wnd, int x, int y, int w, int h);
 
@@ -118,6 +132,13 @@
   IrixOverlayShmImage(Display *d, int width, int height);
   virtual ~IrixOverlayShmImage();
 
+  virtual const char *className() const {
+    return "IrixOverlayShmImage";
+  }
+  virtual const char *classDesc() const {
+    return "IRIX-specific SHM-aware overlay image";
+  }
+
   virtual void get(Window wnd, int x = 0, int y = 0);
   virtual void get(Window wnd, int x, int y, int w, int h);
 
@@ -156,6 +177,13 @@
   SolarisOverlayImage(Display *d, int width, int height);
   virtual ~SolarisOverlayImage();
 
+  virtual const char *className() const {
+    return "SolarisOverlayImage";
+  }
+  virtual const char *classDesc() const {
+    return "Solaris-specific non-SHM overlay image";
+  }
+
   virtual void get(Window wnd, int x = 0, int y = 0);
   virtual void get(Window wnd, int x, int y, int w, int h);
 
diff --git a/x0vncserver/PollingManager.cxx b/x0vncserver/PollingManager.cxx
index 8328101..a823ed4 100644
--- a/x0vncserver/PollingManager.cxx
+++ b/x0vncserver/PollingManager.cxx
@@ -27,12 +27,15 @@
 #include <string.h>
 #include <time.h>
 #include <X11/Xlib.h>
+#include <rfb/LogWriter.h>
 #include <rfb/VNCServer.h>
 #include <rfb/Configuration.h>
 #include <rfb/ServerCore.h>
 
 #include <x0vncserver/PollingManager.h>
 
+static LogWriter vlog("PollingMgr");
+
 BoolParameter PollingManager::pollPointer
 ("PollPointer",
  "DEBUG: Poll area under the pointer with higher priority",
@@ -75,11 +78,20 @@
   // Get initial screen image.
   m_image->get(DefaultRootWindow(m_dpy), m_offsetLeft, m_offsetTop);
 
-  // Create additional images used in the polling algorithm.
-  // FIXME: verify that these images use the same pixel format as in m_image.
+  // Create additional images used in polling algorithms, warn if
+  // underlying class names are different from the class name of the
+  // primary image.
   m_rowImage = factory->newImage(m_dpy, m_width, 1);
   m_tileImage = factory->newImage(m_dpy, 32, 32);
   m_areaImage = factory->newImage(m_dpy, 128, 128);
+  if (strcmp(m_image->className(), m_rowImage->className()) != 0 ||
+      strcmp(m_image->className(), m_tileImage->className()) != 0 ||
+      strcmp(m_image->className(), m_areaImage->className()) != 0) {
+    vlog.error("Image types do not match (%s, %s, %s)",
+               m_rowImage->className(),
+               m_tileImage->className(),
+               m_areaImage->className());
+  }
 
   // FIXME: Extend the comment.
   // Create a matrix with one byte per each 32x32 tile. It will be
diff --git a/x0vncserver/x0vncserver.cxx b/x0vncserver/x0vncserver.cxx
index 530f60e..1f1d0f4 100644
--- a/x0vncserver/x0vncserver.cxx
+++ b/x0vncserver/x0vncserver.cxx
@@ -57,7 +57,7 @@
 using namespace rfb;
 using namespace network;
 
-LogWriter vlog("main");
+LogWriter vlog("Main");
 
 IntParameter pollingCycle("PollingCycle", "Milliseconds per one polling "
                           "cycle; actual interval may be dynamically "
@@ -75,11 +75,16 @@
                                  10);
 StringParameter hostsFile("HostsFile", "File with IP access control rules", "");
 
+//
+// CleanupSignalHandler allows C++ object cleanup to happen because
+// it calls exit() rather than the default which is to abort.
+//
+
 static void CleanupSignalHandler(int sig)
 {
-  // CleanupSignalHandler allows C++ object cleanup to happen because it calls
-  // exit() rather than the default which is to abort.
+#ifdef DEBUG
   fprintf(stderr,"CleanupSignalHandler called\n");
+#endif
   exit(1);
 }
 
@@ -172,6 +177,7 @@
     // Create an image for maintaining framebuffer data.
     ImageFactory factory((bool)useShm, (bool)useOverlay);
     image = factory.newImage(dpy, geometry->width(), geometry->height());
+    vlog.info("Allocated %s", image->classDesc());
 
     // Create polling manager object. It will track screen changes and
     // keep pixels of the `image' object up to date.