[couchdb-glib] Don't set up the custom log_handler for all debug messages. Instead define 'Couchdb-GLib' log domain
- From: Rodrigo Moya <rodrigo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [couchdb-glib] Don't set up the custom log_handler for all debug messages. Instead define 'Couchdb-GLib' log domain
- Date: Tue, 31 Aug 2010 13:50:12 +0000 (UTC)
commit 9579eea00450738b2c5b3588240740e2c4d6d946
Author: Krzysztof Klimonda <kklimonda ubuntu com>
Date: Tue Aug 31 15:49:58 2010 +0200
Don't set up the custom log_handler for all debug messages. Instead define 'Couchdb-GLib' log domain and handle only messages related to library itself
couchdb-glib/Makefile.am | 3 ++-
couchdb-glib/couchdb-session.c | 10 +++++++---
couchdb-glib/xmalloc.c | 2 +-
3 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/couchdb-glib/Makefile.am b/couchdb-glib/Makefile.am
index 6eec82c..6d4f9ad 100644
--- a/couchdb-glib/Makefile.am
+++ b/couchdb-glib/Makefile.am
@@ -9,7 +9,8 @@ OAUTH_FILES =
endif
INCLUDES = \
- $(COUCHDB_GLIB_CFLAGS)
+ $(COUCHDB_GLIB_CFLAGS) \
+ -DG_LOG_DOMAIN=\"Couchdb-GLib\"
lib_LTLIBRARIES = libcouchdb-glib-1.0.la
diff --git a/couchdb-glib/couchdb-session.c b/couchdb-glib/couchdb-session.c
index bb74dc9..9d38fd7 100644
--- a/couchdb-glib/couchdb-session.c
+++ b/couchdb-glib/couchdb-session.c
@@ -193,7 +193,7 @@ couchdb_session_init (CouchdbSession *session)
session->priv->credentials = NULL;
#ifdef DEBUG_MESSAGES
- g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, debug_message, NULL);
+ g_log_set_handler ("Couchdb-GLib", G_LOG_LEVEL_DEBUG, debug_message, NULL);
#endif
}
@@ -562,7 +562,9 @@ _session_authenticate(SoupSession *http_session, SoupMessage *msg,
if (retrying) {
g_signal_emit_by_name (session, COUCHDB_SIGNAL_AUTHENTICATION_FAILED, NULL);
+#ifdef DEBUG_MESSAGES
g_debug ("Authentication failed!");
+#endif
return FALSE;
}
@@ -664,7 +666,9 @@ parse_json_response (CouchdbSession *session, JsonParser *json_parser, SoupMessa
}
if (str && str->len > 0) {
+#ifdef DEBUG_MESSAGES
g_debug ("Response body: %s", str->str);
+#endif
if (!json_parser_load_from_data (json_parser,
(const gchar *) str->str,
str->len,
@@ -726,8 +730,8 @@ couchdb_session_send_message (CouchdbSession *session, const char *method, const
}
}
- g_debug ("Sending %s to %s... with headers\n: ", method, url);
#ifdef DEBUG_MESSAGES
+ g_debug ("Sending %s to %s... with headers: ", method, url);
soup_message_headers_foreach (http_message->request_headers,
(SoupMessageHeadersForeachFunc) debug_print_headers,
NULL);
@@ -763,7 +767,7 @@ debug_message (const gchar *log_domain, GLogLevelFlags log_level,
couchdb_env_debug_messages = g_getenv(COUCHDB_ENV_DEBUG_MESSAGES);
if (couchdb_env_debug_messages != NULL) {
- g_print ("couchdb-glib:DEBUG: %s\n", message);
+ g_print ("%s-DEBUG: %s\n", log_domain, message);
}
}
#endif
diff --git a/couchdb-glib/xmalloc.c b/couchdb-glib/xmalloc.c
index a190d5a..c176171 100644
--- a/couchdb-glib/xmalloc.c
+++ b/couchdb-glib/xmalloc.c
@@ -86,7 +86,7 @@ fixup_null_alloc (n)
{
/* possible revisions: release some memory and re-try, print
more information (e.g. line number of input file) */
- g_debug(_("liboauth: Memory exhausted"));
+ g_critical("liboauth: Memory exhausted");
exit(1);
}
return p;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]