]> git.0d.be Git - empathy.git/commitdiff
Add EMPATHY_LOGFILE env variable. Fixes bug #455240 (Guillaume Desmottes).
authorXavier Claessens <xclaesse@gmail.com>
Mon, 9 Jul 2007 18:59:01 +0000 (18:59 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Mon, 9 Jul 2007 18:59:01 +0000 (18:59 +0000)
2007-07-09 Xavier Claessens  <xclaesse@gmail.com>

* src/empathy.c:
* libempathy/empathy-debug.c:
* libempathy/empathy-debug.h: Add EMPATHY_LOGFILE env variable. Fixes
bug #455240 (Guillaume Desmottes).

svn path=/trunk/; revision=179

ChangeLog
libempathy/empathy-debug.c
libempathy/empathy-debug.h
src/empathy.c

index 0823abdbb6b1c22e488ee9c17b1fdae90b05ea63..4a5bb445c944387a52ed87a4fbd77d3f00640a11 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-07-09 Xavier Claessens  <xclaesse@gmail.com>
+
+       * src/empathy.c:
+       * libempathy/empathy-debug.c:
+       * libempathy/empathy-debug.h: Add EMPATHY_LOGFILE env variable. Fixes
+       bug #455240 (Guillaume Desmottes).
+
 2007-07-09 Xavier Claessens  <xclaesse@gmail.com>
 
        * libempathy-gtk/empathy-account-widget-msn.glade:
index 2f565849988b07b5aa29ca879cb7dd673d63e168..c3e5d74b0118e8499918fbd39576af3c2effc42b 100644 (file)
 
 #include <stdarg.h>
 #include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
 
 #include <glib.h>
 #include <glib/gprintf.h>
+#include <glib/gstdio.h>
 
 /* Set EMPATHY_DEBUG to a colon/comma/space separated list of domains, or "all"
  * to get all debug output.
@@ -90,3 +96,34 @@ empathy_debug_impl (const gchar *domain, const gchar *msg, ...)
        }
 }
 
+void
+empathy_debug_set_log_file_from_env (void)
+{
+       const gchar *output_file;
+       gint         out;
+
+       output_file = g_getenv ("EMPATHY_LOGFILE");
+       if (output_file == NULL) {
+               return;
+       }
+
+       out = g_open (output_file, O_WRONLY | O_CREAT, 0644);
+       if (out == -1) {
+               g_warning ("Can't open logfile '%s': %s", output_file,
+                          g_strerror (errno));
+               return;
+       }
+
+       if (dup2 (out, STDOUT_FILENO) == -1) {
+               g_warning ("Error when duplicating stdout file descriptor: %s",
+                          g_strerror (errno));
+               return;
+       }
+
+       if (dup2 (out, STDERR_FILENO) == -1) {
+               g_warning ("Error when duplicating stderr file descriptor: %s",
+                          g_strerror (errno));
+               return;
+       }
+}
+
index 19d2aa3806c9b24cfd50e6c95d3a5a38c7fc642d..fca53f4bd258ea6c2228cf16a5d32bfa87702314 100644 (file)
@@ -45,7 +45,10 @@ G_BEGIN_DECLS
 #  endif
 #endif
 
-void empathy_debug_impl (const gchar *domain, const gchar *msg, ...);
+void empathy_debug_impl                  (const gchar *domain,
+                                         const gchar *msg,
+                                         ...);
+void empathy_debug_set_log_file_from_env (void);
 
 G_END_DECLS
 
index 416d2134dae6f4d543bb8c5319555628fcd261a5..9a764cef33f0aaab5f5c93afc598e788afd1dd3a 100644 (file)
@@ -167,6 +167,8 @@ main (int argc, char *argv[])
                { NULL }
        };
 
+       empathy_debug_set_log_file_from_env ();
+
        bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
        textdomain (GETTEXT_PACKAGE);