[evolution] Make it possible to debug filters on stdout



commit 9fa8f168018e05d3eabcfe7604c4cad4e96a9482
Author: Milan Crha <mcrha redhat com>
Date:   Mon Jun 26 15:42:25 2017 +0200

    Make it possible to debug filters on stdout
    
    Two changes being done:
    a) special value 'stdout', or an empty string, for 'filters-log-file'
       will make logging into stdout
    b) running with CAMEL_DEBUG=filters also turns on logging to stdout.
    
    The output file from GSettings has precedence over the stdout used
    by CAMEL_DEBUG, when both loggings are enabled. In other words, in case
    GSettings has enabled logging, then GSettings dictate which file is
    used for the log, otherwise GSettings values are ignored and stdout
    is used only when CAMEL_DEBUG logging is enabled.

 data/org.gnome.evolution.mail.gschema.xml.in |    2 +-
 src/mail/e-mail-ui-session.c                 |   14 +++++++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/data/org.gnome.evolution.mail.gschema.xml.in b/data/org.gnome.evolution.mail.gschema.xml.in
index 99244c0..8f5d928 100644
--- a/data/org.gnome.evolution.mail.gschema.xml.in
+++ b/data/org.gnome.evolution.mail.gschema.xml.in
@@ -426,7 +426,7 @@
     <key name="filters-log-file" type="s">
       <default>''</default>
       <_summary>Logfile to log filter actions</_summary>
-      <_description>Logfile to log filter actions.</_description>
+      <_description>If not set, or being 'stdout', then the logging is done to stdout, instead to a 
file.</_description>
     </key>
     <key name="flush-outbox" type="b">
       <default>false</default>
diff --git a/src/mail/e-mail-ui-session.c b/src/mail/e-mail-ui-session.c
index 7771949..a3b5a7b 100644
--- a/src/mail/e-mail-ui-session.c
+++ b/src/mail/e-mail-ui-session.c
@@ -251,15 +251,23 @@ main_get_filter_driver (CamelSession *session,
        driver = camel_filter_driver_new (session);
        camel_filter_driver_set_folder_func (driver, get_folder, session);
 
-       if (g_settings_get_boolean (settings, "filters-log-actions")) {
-               if (priv->filter_logfile == NULL) {
+       if (g_settings_get_boolean (settings, "filters-log-actions") ||
+           camel_debug ("filters")) {
+               if (!priv->filter_logfile &&
+                   g_settings_get_boolean (settings, "filters-log-actions")) {
                        gchar *filename;
 
                        filename = g_settings_get_string (settings, "filters-log-file");
                        if (filename) {
-                               priv->filter_logfile = g_fopen (filename, "a+");
+                               if (!*filename || g_strcmp0 (filename, "stdout") == 0)
+                                       priv->filter_logfile = stdout;
+                               else
+                                       priv->filter_logfile = g_fopen (filename, "a+");
+
                                g_free (filename);
                        }
+               } else if (!priv->filter_logfile) {
+                       priv->filter_logfile = stdout;
                }
 
                if (priv->filter_logfile)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]