Commit 9fa8f168 authored by Milan Crha's avatar Milan Crha
Browse files

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.
parent 2193e408
......@@ -426,7 +426,7 @@
<key name="filters-log-file" type="s">
<_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 name="flush-outbox" type="b">
......@@ -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;
priv->filter_logfile = g_fopen (filename, "a+");
g_free (filename);
} else if (!priv->filter_logfile) {
priv->filter_logfile = stdout;
if (priv->filter_logfile)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment