[Bugfix] Register GNUTLS debug routines only when we actually need them.


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4295 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/common/rfb/CSecurityTLS.cxx b/common/rfb/CSecurityTLS.cxx
index c774c3d..6028792 100644
--- a/common/rfb/CSecurityTLS.cxx
+++ b/common/rfb/CSecurityTLS.cxx
@@ -62,23 +62,18 @@
 #define WITHOUT_X509_TIMES
 #endif
 
-#define TLS_DEBUG
-
 using namespace rfb;
 
 StringParameter CSecurityTLS::x509ca("x509ca", "X509 CA certificate", "", ConfViewer);
 StringParameter CSecurityTLS::x509crl("x509crl", "X509 CRL file", "", ConfViewer);
 
 static LogWriter vlog("TLS");
-
-#ifdef TLS_DEBUG
-static LogWriter vlog_raw("Raw TLS");
+static LogWriter vlog_raw("RawTLS");
 
 static void debug_log(int level, const char* str)
 {
   vlog_raw.debug(str);
 }
-#endif
 
 void CSecurityTLS::initGlobal()
 {
@@ -87,10 +82,11 @@
   if (!globalInitDone) {
     gnutls_global_init();
 
-#ifdef TLS_DEBUG
-    gnutls_global_set_log_level(10);
-    gnutls_global_set_log_function(debug_log);
-#endif
+    /* 100 means debug log */
+    if (vlog_raw.getLevel() >= 100) {
+      gnutls_global_set_log_level(10);
+      gnutls_global_set_log_function(debug_log);
+    }
 
     globalInitDone = true;
   }