浏览代码

GnuTLS: Setup logging

Nils Maier 11 年之前
父节点
当前提交
7777e1cb37
共有 1 个文件被更改,包括 13 次插入0 次删除
  1. 13 0
      src/Platform.cc

+ 13 - 0
src/Platform.cc

@@ -66,9 +66,19 @@
 #ifdef HAVE_LIBGMP
 # include "a2gmp.h"
 #endif // HAVE_LIBGMP
+#include "LogFactory.h"
 
 #define A2_MIN_GCRYPT_VERSION "1.2.4"
 
+namespace {
+  void gnutls_log_callback(int level, const char *str)
+  {
+    using namespace aria2;
+    A2_LOG_DEBUG(fmt("GNUTLS: %d / %s", level, str));
+  }
+}
+
+
 namespace aria2 {
 
 bool Platform::initialized_ = false;
@@ -120,6 +130,9 @@ bool Platform::setUp()
       throw DL_ABORT_EX(fmt("gnutls_global_init() failed, cause:%s",
                             gnutls_strerror(r)));
     }
+
+    gnutls_global_set_log_function(gnutls_log_callback);
+    gnutls_global_set_log_level(10);
   }
 #endif // HAVE_LIBGNUTLS