evolution-jescs r261 - in trunk: . lib storage
- From: jedywang svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-jescs r261 - in trunk: . lib storage
- Date: Mon, 11 Aug 2008 11:01:18 +0000 (UTC)
Author: jedywang
Date: Mon Aug 11 11:01:18 2008
New Revision: 261
URL: http://svn.gnome.org/viewvc/evolution-jescs?rev=261&view=rev
Log:
2008-08-11 Wang Xin <jedy wang sun com>
Update the code to use the debug log support provided by libsoup.
* lib/sunone-message.[ch]: Remove the code related with the old logger.
* lib/sunone-connection.c: New logger support.
* storage/main.c: New logger support.
Modified:
trunk/ChangeLog
trunk/lib/sunone-connection.c
trunk/lib/sunone-message.c
trunk/lib/sunone-message.h
trunk/storage/main.c
Modified: trunk/lib/sunone-connection.c
==============================================================================
--- trunk/lib/sunone-connection.c (original)
+++ trunk/lib/sunone-connection.c Mon Aug 11 11:01:18 2008
@@ -47,6 +47,11 @@
GHashTable *wcaps;
};
+#if SUNONE_DEBUG
+gchar *verbose_debug;
+gint debug_level;
+#endif
+
static gchar *get_acls_string (GList *acls);
static gboolean reconnect_timeout_cb (gpointer user_data);
@@ -615,6 +620,10 @@
{
SunOneConnection *connection = SUNONE_CONNECTION (object);
SunOneConnectionPrivate *priv;
+#if SUNONE_DEBUG
+ SoupLogger *logger;
+ SoupLoggerLogLevel level;
+#endif
connection->priv = g_new0 (SunOneConnectionPrivate, 1);
priv = connection->priv;
@@ -624,6 +633,15 @@
priv->timeout_id = -1;
priv->is_open = FALSE;
priv->wcaps = g_hash_table_new (g_str_hash, g_str_equal);
+
+#if SUNONE_DEBUG
+ if (debug_level < 4 && debug_level >= 0)
+ level = (SoupLoggerLogLevel)debug_level;
+ else
+ level = SOUP_LOGGER_LOG_BODY;
+ logger = soup_logger_new (level, -1);
+ soup_session_add_feature (priv->soup_session, SOUP_SESSION_FEATURE (logger));
+#endif
}
Modified: trunk/lib/sunone-message.c
==============================================================================
--- trunk/lib/sunone-message.c (original)
+++ trunk/lib/sunone-message.c Mon Aug 11 11:01:18 2008
@@ -20,19 +20,8 @@
#include "sunone-util.h"
#include "sunone-message.h"
-gboolean jescs_verbose_debug = FALSE;
-gboolean jescs_long_debug = FALSE;
#define RESPONSE_MAX_LENGTH 65535
-void sunone_message_init ()
-{
- if (getenv ("EVOLUTION_JESCS_VERBOSE_DEBUG"))
- jescs_verbose_debug = TRUE;
- if (getenv ("EVOLUTION_JESCS_LONG_DEBUG"))
- jescs_long_debug = TRUE;
-
-}
-
SoupMessage *
sunone_message_new_from_uri (SoupURI *suri, const char *method)
{
@@ -61,68 +50,11 @@
return msg;
}
-#ifdef SUNONE_DEBUG
-static void
-print_header (const char *name, const char *value, gpointer data)
-{
- printf ("%s: %s\n", name, value);
-}
-
-static void
-sunone_debug_handler (SoupMessage *msg, gpointer user_data)
-{
- if (jescs_verbose_debug) {
- printf ("%d %s (%p @ %lu)\n", msg->status_code, msg->reason_phrase,
- msg, time (0));
- soup_message_headers_foreach (msg->response_headers,
- print_header, NULL);
- if (msg->response_body->length &&
- SUNONE_ERROR_IS_SUCCESSFUL (msg->status_code)) {
- if (jescs_long_debug) {
- printf ("\n%.*s\n", (int) msg->response_body->length,
- msg->response_body->data);
- } else {
- if (msg->response_body->length < RESPONSE_MAX_LENGTH)
- printf ("\n%.*s\n", (int) msg->response_body->length,
- msg->response_body->data);
- else
- printf ("\n%.*s\n", RESPONSE_MAX_LENGTH,
- msg->response_body->data);
- }
- }
- printf ("\n");
- }
-}
-#endif
-
void
setup_message (SoupMessage *msg)
{
soup_message_headers_append (msg->request_headers, "User-Agent",
"Evolution/" EVOLUTION_VERSION);
-
-#ifdef SUNONE_DEBUG
- if (jescs_verbose_debug)
- {
- const SoupURI *uri = soup_message_get_uri (msg);
-
- printf ("%s %s%s%s HTTP/1.1 (%p @ %lu)\n",
- msg->method, uri->path,
- uri->query ? "?" : "",
- uri->query ? uri->query : "",
- msg, (unsigned long)time (0));
- soup_message_headers_foreach (msg->request_headers,
- print_header, NULL);
- if (msg->request_body->length) {
- printf ("\n%.*s\n", (int)msg->request_body->length,
- msg->request_body->data);
- }
- printf ("\n");
-
- g_signal_connect (msg, "got-headers",
- G_CALLBACK (sunone_debug_handler), NULL);
- }
-#endif
}
void
Modified: trunk/lib/sunone-message.h
==============================================================================
--- trunk/lib/sunone-message.h (original)
+++ trunk/lib/sunone-message.h Mon Aug 11 11:01:18 2008
@@ -19,7 +19,6 @@
G_BEGIN_DECLS
-void sunone_message_init (void);
SoupMessage *sunone_message_new_from_uri (SoupURI *suri, const char *method);
SoupMessage *sunone_message_new_full_from_uri (SoupURI *suri, const char *method, const char *content_type, SoupMemoryUse req_use, char *body, gulong length);
void parse_server_response (SoupMessage *msg, guint *status);
Modified: trunk/storage/main.c
==============================================================================
--- trunk/storage/main.c (original)
+++ trunk/storage/main.c Mon Aug 11 11:01:18 2008
@@ -34,6 +34,11 @@
#define CLEAN_WCAP 0
+#if SUNONE_DEBUG
+extern gchar *verbose_debug;
+extern gint debug_level;
+#endif
+
static EDataCalFactory *calendar_factory = NULL;
char *evolution_dir;
static BonoboGenericFactory *component_factory = NULL;
@@ -173,7 +178,6 @@
camel_init (evolution_dir, FALSE);
#endif
e_passwords_init ();
- sunone_message_init ();
#if CLEAN_WCAP
/* remove trash esources if possible */
@@ -195,16 +199,18 @@
/* run the application */
g_message ("Evolution-jescs up and running!\n");
- if (getenv ("EVOLUTION_JESCS_VERBOSE_DEBUG")) {
- /* Redirect stderr to stdout and make it line-buffered
- * rather than block-buffered, for ease of debug
- * redirection.
- */
- dup2 (STDOUT_FILENO, STDERR_FILENO);
- setvbuf (stdout, NULL, _IOLBF, 0);
- setvbuf (stderr, NULL, _IOLBF, 0);
- printf ("EVOLUTION_JESCS_VERBOSE_DEBUG=1\n");
- }
+ verbose_debug = getenv ("EVOLUTION_JESCS_VERBOSE_DEBUG");
+ if (verbose_debug) {
+ /* Redirect stderr to stdout and make it line-buffered
+ * rather than block-buffered, for ease of debug
+ * redirection.
+ */
+ debug_level = atoi (verbose_debug);
+ dup2 (STDOUT_FILENO, STDERR_FILENO);
+ setvbuf (stdout, NULL, _IOLBF, 0);
+ setvbuf (stderr, NULL, _IOLBF, 0);
+ printf ("EVOLUTION_JESCS_VERBOSE_DEBUG=%d\n", debug_level);
+ }
bonobo_main ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]