diff options
author | Pekka Pessi <Pekka.Pessi@nokia.com> | 2011-02-07 20:23:22 +0200 |
---|---|---|
committer | Pekka Pessi <Pekka.Pessi@nokia.com> | 2011-02-07 22:00:57 +0200 |
commit | 1aaf4b3483608bd24d4589c8fdd3012c8c5de3e9 (patch) | |
tree | 03f65403fb345b1d59de4d383bb7f381916f154e | |
parent | 92a9e89842b9308a11613760934eeaf8d80b470a (diff) |
telepathy-sofiasip.c: use tpsip Sofia log handling
-rw-r--r-- | src/telepathy-sofiasip.c | 59 |
1 files changed, 2 insertions, 57 deletions
diff --git a/src/telepathy-sofiasip.c b/src/telepathy-sofiasip.c index dfdf5e8..e3cc812 100644 --- a/src/telepathy-sofiasip.c +++ b/src/telepathy-sofiasip.c @@ -32,8 +32,6 @@ #include <telepathy-glib/run.h> #include <telepathy-glib/debug.h> -#include <sofia-sip/su_log.h> - static TpBaseConnectionManager * construct_cm (void) { @@ -41,59 +39,6 @@ construct_cm (void) TPSIP_TYPE_CONNECTION_MANAGER, NULL); } -static void -sofia_log_handler (void *logdata, const char *format, va_list args) -{ -#ifdef ENABLE_DEBUG - GString *buf = (GString *)logdata; - g_assert (buf != NULL); - - /* Append the formatted message at the end of the buffer */ - g_string_append_vprintf (buf, format, args); - - /* If we have a terminated line, log it, stripping the newline */ - if (buf->str[buf->len - 1] == '\n') - { - g_string_truncate (buf, buf->len - 1); - tpsip_log (TPSIP_DEBUG_SOFIA, G_LOG_LEVEL_DEBUG, "%s", buf->str); - g_string_truncate (buf, 0); - } -#endif -} - -static gpointer -sofia_log_init () -{ - GString *buf; - -#ifdef ENABLE_DEBUG - buf = g_string_sized_new (80); -#else - buf = NULL; -#endif - - su_log_redirect (NULL, sofia_log_handler, buf); - - return buf; -} - -static void -sofia_log_finalize (gpointer logdata) -{ -#ifdef ENABLE_DEBUG - GString *buf = (GString *)logdata; - - if (buf->len != 0) - { - /* Don't use tpsip_log here because the CM has already been finalized, so - * out TpDebugSender will have too. It isn't crucial, anyway. */ - g_debug ("%s", buf->str); - g_message ("last Sofia log message was not newline-terminated"); - } - - g_string_free (buf, TRUE); -#endif -} int main (int argc, char** argv) @@ -117,12 +62,12 @@ main (int argc, char** argv) tp_debug_divert_messages (g_getenv ("TPSIP_LOGFILE")); - logdata = sofia_log_init (); + logdata = tpsip_sofia_log_init (); status = tp_run_connection_manager ("telepathy-sofiasip", VERSION, construct_cm, argc, argv); - sofia_log_finalize (logdata); + tpsip_sofia_log_finalize (logdata); return status; } |