Mercurial > pidgin
diff libpurple/plugins/ssl/ssl-gnutls.c @ 27183:e997e1e9b4f1
Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.
Refs #9338.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Fri, 26 Jun 2009 05:11:01 +0000 |
parents | c19d892f4381 |
children | 0ac5a002dd6d |
line wrap: on
line diff
--- a/libpurple/plugins/ssl/ssl-gnutls.c Fri Jun 26 04:46:15 2009 +0000 +++ b/libpurple/plugins/ssl/ssl-gnutls.c Fri Jun 26 05:11:01 2009 +0000 @@ -43,8 +43,17 @@ static gnutls_certificate_client_credentials xcred; static void +ssl_gnutls_log(int level, const char *str) +{ + /* GnuTLS log messages include the '\n' */ + purple_debug_misc("gnutls", "lvl %d: %s", level, str); +} + +static void ssl_gnutls_init_gnutls(void) { + const char *debug_level; + /* Configure GnuTLS to use glib memory management */ /* I expect that this isn't really necessary, but it may prevent some bugs */ @@ -59,6 +68,20 @@ (gnutls_free_function) g_free /* free */ ); + debug_level = g_getenv("PURPLE_GNUTLS_DEBUG"); + if (debug_level) { + int level = atoi(debug_level); + if (level < 0) { + purple_debug_warning("gnutls", "Assuming log level 0 instead of %d\n", + level); + level = 0; + } + + /* "The level is an integer between 0 and 9. Higher values mean more verbosity." */ + gnutls_global_set_log_level(level); + gnutls_global_set_log_function(ssl_gnutls_log); + } + gnutls_global_init(); gnutls_certificate_allocate_credentials(&xcred);