فهرست منبع

protect debug statements

David Rose 20 سال پیش
والد
کامیت
e79df2bfcc

+ 17 - 15
panda/src/downloader/httpClient.cxx

@@ -832,21 +832,23 @@ load_client_certificate() {
         sev = NS_info;
         source = _client_certificate_filename;
       }
-      
-      if (_client_certificate_priv != (EVP_PKEY *)NULL &&
-          _client_certificate_pub != (X509 *)NULL) {
-        downloader_cat.out(sev) 
-          << "Read client certificate from " << source << "\n";
-        
-      } else {
-        if (_client_certificate_priv == (EVP_PKEY *)NULL) {
-          downloader_cat.out(sev)
-            << "Could not read private key from " << source << "\n";
-        }
-        
-        if (_client_certificate_pub == (X509 *)NULL) {
-          downloader_cat.out(sev)
-            << "Could not read public key from " << source << "\n";
+
+      if (downloader_cat.is_on(sev)) {
+        if (_client_certificate_priv != (EVP_PKEY *)NULL &&
+            _client_certificate_pub != (X509 *)NULL) {
+          downloader_cat.out(sev) 
+            << "Read client certificate from " << source << "\n";
+          
+        } else {
+          if (_client_certificate_priv == (EVP_PKEY *)NULL) {
+            downloader_cat.out(sev)
+              << "Could not read private key from " << source << "\n";
+          }
+          
+          if (_client_certificate_pub == (X509 *)NULL) {
+            downloader_cat.out(sev)
+              << "Could not read public key from " << source << "\n";
+          }
         }
       }
     }

+ 53 - 19
panda/src/glxdisplay/glxGraphicsPipe.cxx

@@ -533,8 +533,10 @@ try_for_fbconfig(int framebuffer_mode,
   int attrib_list[max_attrib_list];
   int n=0;
 
-  glxdisplay_cat.debug()
-    << "Trying for fbconfig with: RGB(" << want_color_bits << ")";
+  if (glxdisplay_cat.is_debug()) {
+    glxdisplay_cat.debug()
+      << "Trying for fbconfig with: RGB(" << want_color_bits << ")";
+  }
 
   int want_color_component_bits = max(want_color_bits / 3, 1);
 
@@ -546,28 +548,36 @@ try_for_fbconfig(int framebuffer_mode,
   attrib_list[n++] = want_color_component_bits;
 
   if (framebuffer_mode & FrameBufferProperties::FM_alpha) {
-    glxdisplay_cat.debug(false) << " ALPHA(" << want_alpha_bits << ")";
+    if (glxdisplay_cat.is_debug()) {
+      glxdisplay_cat.debug(false) << " ALPHA(" << want_alpha_bits << ")";
+    }
     attrib_list[n++] = GLX_ALPHA_SIZE;
     attrib_list[n++] = want_alpha_bits;
   }
 
   switch (framebuffer_mode & FrameBufferProperties::FM_buffer) {
   case FrameBufferProperties::FM_single_buffer:
-    glxdisplay_cat.debug(false) << " SINGLEBUFFER";
+    if (glxdisplay_cat.is_debug()) {
+      glxdisplay_cat.debug(false) << " SINGLEBUFFER";
+    }
     attrib_list[n++] = GLX_DOUBLEBUFFER;
     attrib_list[n++] = false;
     break;
 
   case FrameBufferProperties::FM_double_buffer:
   case FrameBufferProperties::FM_triple_buffer:
-    glxdisplay_cat.debug(false) << " DOUBLEBUFFER";
+    if (glxdisplay_cat.is_debug()) {
+      glxdisplay_cat.debug(false) << " DOUBLEBUFFER";
+    }
     attrib_list[n++] = GLX_DOUBLEBUFFER;
     attrib_list[n++] = true;
     break;
   }
 
   if (framebuffer_mode & FrameBufferProperties::FM_stereo) {
-    glxdisplay_cat.debug(false) << " STEREO";
+    if (glxdisplay_cat.is_debug()) {
+      glxdisplay_cat.debug(false) << " STEREO";
+    }
     attrib_list[n++] = GLX_STEREO;
     attrib_list[n++] = true;
   } else {
@@ -576,19 +586,25 @@ try_for_fbconfig(int framebuffer_mode,
   }
 
   if (framebuffer_mode & FrameBufferProperties::FM_depth) {
-    glxdisplay_cat.debug(false) << " DEPTH(" << want_depth_bits << ")";
+    if (glxdisplay_cat.is_debug()) {
+      glxdisplay_cat.debug(false) << " DEPTH(" << want_depth_bits << ")";
+    }
     attrib_list[n++] = GLX_DEPTH_SIZE;
     attrib_list[n++] = want_depth_bits;
   }
 
   if (framebuffer_mode & FrameBufferProperties::FM_stencil) {
-    glxdisplay_cat.debug(false) << " STENCIL(" << want_stencil_bits << ")";
+    if (glxdisplay_cat.is_debug()) {
+      glxdisplay_cat.debug(false) << " STENCIL(" << want_stencil_bits << ")";
+    }
     attrib_list[n++] = GLX_STENCIL_SIZE;
     attrib_list[n++] = want_stencil_bits;
   }
 
   if (framebuffer_mode & FrameBufferProperties::FM_accum) {
-    glxdisplay_cat.debug(false) << " ACCUM";
+    if (glxdisplay_cat.is_debug()) {
+      glxdisplay_cat.debug(false) << " ACCUM";
+    }
     attrib_list[n++] = GLX_ACCUM_RED_SIZE;
     attrib_list[n++] = want_color_component_bits;
     attrib_list[n++] = GLX_ACCUM_GREEN_SIZE;
@@ -602,7 +618,9 @@ try_for_fbconfig(int framebuffer_mode,
   }
 
   if (framebuffer_mode & FrameBufferProperties::FM_multisample) {
-    glxdisplay_cat.debug(false) << " MULTISAMPLE(" << want_multisamples << ")";
+    if (glxdisplay_cat.is_debug()) {
+      glxdisplay_cat.debug(false) << " MULTISAMPLE(" << want_multisamples << ")";
+    }
     attrib_list[n++] = GLX_SAMPLE_BUFFERS;
     attrib_list[n++] = 1;
     attrib_list[n++] = GLX_SAMPLES;
@@ -838,8 +856,10 @@ try_for_visual(int framebuffer_mode,
   int attrib_list[max_attrib_list];
   int n=0;
 
-  glxdisplay_cat.debug()
-    << "Trying for visual with: RGB(" << want_color_bits << ")";
+  if (glxdisplay_cat.is_debug()) {
+    glxdisplay_cat.debug()
+      << "Trying for visual with: RGB(" << want_color_bits << ")";
+  }
 
   int want_color_component_bits = max(want_color_bits / 3, 1);
 
@@ -852,30 +872,42 @@ try_for_visual(int framebuffer_mode,
   attrib_list[n++] = want_color_component_bits;
 
   if (framebuffer_mode & FrameBufferProperties::FM_alpha) {
-    glxdisplay_cat.debug(false) << " ALPHA(" << want_alpha_bits << ")";
+    if (glxdisplay_cat.is_debug()) {
+      glxdisplay_cat.debug(false) << " ALPHA(" << want_alpha_bits << ")";
+    }
     attrib_list[n++] = GLX_ALPHA_SIZE;
     attrib_list[n++] = want_alpha_bits;
   }
   if (framebuffer_mode & FrameBufferProperties::FM_double_buffer) {
-    glxdisplay_cat.debug(false) << " DOUBLEBUFFER";
+    if (glxdisplay_cat.is_debug()) {
+      glxdisplay_cat.debug(false) << " DOUBLEBUFFER";
+    }
     attrib_list[n++] = GLX_DOUBLEBUFFER;
   }
   if (framebuffer_mode & FrameBufferProperties::FM_stereo) {
-    glxdisplay_cat.debug(false) << " STEREO";
+    if (glxdisplay_cat.is_debug()) {
+      glxdisplay_cat.debug(false) << " STEREO";
+    }
     attrib_list[n++] = GLX_STEREO;
   }
   if (framebuffer_mode & FrameBufferProperties::FM_depth) {
-    glxdisplay_cat.debug(false) << " DEPTH(" << want_depth_bits << ")";
+    if (glxdisplay_cat.is_debug()) {
+      glxdisplay_cat.debug(false) << " DEPTH(" << want_depth_bits << ")";
+    }
     attrib_list[n++] = GLX_DEPTH_SIZE;
     attrib_list[n++] = want_depth_bits;
   }
   if (framebuffer_mode & FrameBufferProperties::FM_stencil) {
-    glxdisplay_cat.debug(false) << " STENCIL(" << want_stencil_bits << ")";
+    if (glxdisplay_cat.is_debug()) {
+      glxdisplay_cat.debug(false) << " STENCIL(" << want_stencil_bits << ")";
+    }
     attrib_list[n++] = GLX_STENCIL_SIZE;
     attrib_list[n++] = want_stencil_bits;
   }
   if (framebuffer_mode & FrameBufferProperties::FM_accum) {
-    glxdisplay_cat.debug(false) << " ACCUM";
+    if (glxdisplay_cat.is_debug()) {
+      glxdisplay_cat.debug(false) << " ACCUM";
+    }
     attrib_list[n++] = GLX_ACCUM_RED_SIZE;
     attrib_list[n++] = want_color_component_bits;
     attrib_list[n++] = GLX_ACCUM_GREEN_SIZE;
@@ -888,7 +920,9 @@ try_for_visual(int framebuffer_mode,
     }
   }
   if (framebuffer_mode & FrameBufferProperties::FM_multisample) {
-    glxdisplay_cat.debug(false) << " MULTISAMPLE(" << want_multisamples << ")";
+    if (glxdisplay_cat.is_debug()) {
+      glxdisplay_cat.debug(false) << " MULTISAMPLE(" << want_multisamples << ")";
+    }
     attrib_list[n++] = GLX_SAMPLES;
     attrib_list[n++] = want_multisamples;
   }

+ 5 - 3
panda/src/glxdisplay/glxGraphicsStateGuardian.cxx

@@ -192,9 +192,11 @@ query_gl_version() {
   // We output to glgsg_cat instead of glxdisplay_cat, since this is
   // where the GL version has been output, and it's nice to see the
   // two of these together.
-  glgsg_cat.debug()
-    << "GLX_VERSION = " << _glx_version_major << "." << _glx_version_minor 
-    << "\n";
+  if (glgsg_cat.is_debug()) {
+    glgsg_cat.debug()
+      << "GLX_VERSION = " << _glx_version_major << "." << _glx_version_minor 
+      << "\n";
+  }
 }
 
 ////////////////////////////////////////////////////////////////////

+ 25 - 15
panda/src/pgraph/loaderFileTypeRegistry.cxx

@@ -55,9 +55,11 @@ void LoaderFileTypeRegistry::
 register_type(LoaderFileType *type) {
   // Make sure we haven't already registered this type.
   if (find(_types.begin(), _types.end(), type) != _types.end()) {
-    loader_cat->debug()
-      << "Attempt to register LoaderFileType " << type->get_name()
-      << " (" << type->get_type() << ") more than once.\n";
+    if (loader_cat->is_debug()) {
+      loader_cat->debug()
+        << "Attempt to register LoaderFileType " << type->get_name()
+        << " (" << type->get_type() << ") more than once.\n";
+    }
     return;
   }
 
@@ -92,9 +94,11 @@ register_deferred_type(const string &extension, const string &library) {
   if (ei != _extensions.end()) {
     // We already have a loader for this type; no need to register
     // another one.
-    loader_cat->debug()
-      << "Attempt to register loader library " << library
-      << " (" << dcextension << ") when extension is already known.\n";
+    if (loader_cat->is_debug()) {
+      loader_cat->debug()
+        << "Attempt to register loader library " << library
+        << " (" << dcextension << ") when extension is already known.\n";
+    }
     return;
   }
 
@@ -102,14 +106,18 @@ register_deferred_type(const string &extension, const string &library) {
   di = _deferred_types.find(dcextension);
   if (di != _deferred_types.end()) {
     if ((*di).second == library) {
-      loader_cat->debug()
-        << "Attempt to register loader library " << library
-        << " (" << dcextension << ") more than once.\n";
+      if (loader_cat->is_debug()) {
+        loader_cat->debug()
+          << "Attempt to register loader library " << library
+          << " (" << dcextension << ") more than once.\n";
+      }
       return;
     } else {
-      loader_cat->debug()
-        << "Multiple libraries registered that use the extension "
-        << dcextension << "\n";
+      if (loader_cat->is_debug()) {
+        loader_cat->debug()
+          << "Multiple libraries registered that use the extension "
+          << dcextension << "\n";
+      }
     }
   }
 
@@ -246,9 +254,11 @@ record_extension(const string &extension, LoaderFileType *type) {
   Extensions::const_iterator ei;
   ei = _extensions.find(dcextension);
   if (ei != _extensions.end()) {
-    loader_cat->debug()
-      << "Multiple LoaderFileTypes registered that use the extension "
-      << dcextension << "\n";
+    if (loader_cat->is_debug()) {
+      loader_cat->debug()
+        << "Multiple LoaderFileTypes registered that use the extension "
+        << dcextension << "\n";
+    }
   } else {
     _extensions.insert(Extensions::value_type(dcextension, type));
   }