From 9fa8f168018e05d3eabcfe7604c4cad4e96a9482 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Mon, 26 Jun 2017 15:42:25 +0200 Subject: [PATCH] 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 99244c0c60..8f5d928e93 100644 --- a/data/org.gnome.evolution.mail.gschema.xml.in +++ b/data/org.gnome.evolution.mail.gschema.xml.in @@ -426,7 +426,7 @@ '' <_summary>Logfile to log filter actions - <_description>Logfile to log filter actions. + <_description>If not set, or being 'stdout', then the logging is done to stdout, instead to a file. false diff --git a/src/mail/e-mail-ui-session.c b/src/mail/e-mail-ui-session.c index 7771949a36..a3b5a7b941 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)