[geary/mjog/logging-improvements: 10/23] Geary.Logging: Remove Flag enum



commit 3b0815a1dc34a2f646dc7cc8fa555b618ae301e3
Author: Michael Gratton <mike vee net>
Date:   Wed Apr 15 17:03:16 2020 +1000

    Geary.Logging: Remove Flag enum
    
    Now that we have classes logging on sub-domains, and the ability to
    suppress specific domains, remove flags and switch over to doing
    domain suppression for manipulating debug settings in the client.

 src/client/application/application-client.vala     |  72 ++++----
 src/console/main.vala                              |   1 -
 src/engine/api/geary-account.vala                  |   5 -
 src/engine/api/geary-client-service.vala           |   5 -
 src/engine/api/geary-folder.vala                   |   5 -
 src/engine/api/geary-logging.vala                  | 188 +--------------------
 src/engine/app/app-conversation-monitor.vala       |   5 -
 .../conversation-monitor/app-conversation-set.vala |   5 -
 src/engine/db/db-context.vala                      |   8 -
 .../imap-engine/imap-engine-account-operation.vala |   5 -
 .../imap-engine/imap-engine-account-processor.vala |   5 -
 .../imap-engine-account-synchronizer.vala          |   5 -
 .../imap-engine/imap-engine-replay-queue.vala      |   5 -
 src/engine/imap/api/imap-session-object.vala       |   5 -
 .../imap/transport/imap-client-connection.vala     |   5 -
 src/engine/imap/transport/imap-client-session.vala |   9 +-
 src/engine/imap/transport/imap-deserializer.vala   |   5 -
 src/engine/smtp/smtp-client-connection.vala        |   5 -
 src/engine/smtp/smtp-client-session.vala           |   5 -
 src/engine/util/util-logging.vala                  |  65 ++-----
 src/mailer/main.vala                               |   3 +-
 test/test-client.vala                              |   2 -
 test/test-engine.vala                              |   2 -
 23 files changed, 63 insertions(+), 357 deletions(-)
---
diff --git a/src/client/application/application-client.vala b/src/client/application/application-client.vala
index 8df04a06..1f8dfb03 100644
--- a/src/client/application/application-client.vala
+++ b/src/client/application/application-client.vala
@@ -65,10 +65,9 @@ public class Application.Client : Gtk.Application {
     private const string OPTION_LOG_CONVERSATIONS = "log-conversations";
     private const string OPTION_LOG_DESERIALIZER = "log-deserializer";
     private const string OPTION_LOG_FOLDER_NORM = "log-folder-normalization";
-    private const string OPTION_LOG_NETWORK = "log-network";
-    private const string OPTION_LOG_PERIODIC = "log-periodic";
+    private const string OPTION_LOG_IMAP = "log-imap";
     private const string OPTION_LOG_REPLAY_QUEUE = "log-replay-queue";
-    private const string OPTION_LOG_SERIALIZER = "log-serializer";
+    private const string OPTION_LOG_SMTP = "log-smtp";
     private const string OPTION_LOG_SQL = "log-sql";
     private const string OPTION_HIDDEN = "hidden";
     private const string OPTION_NEW_WINDOW = "new-window";
@@ -111,22 +110,17 @@ public class Application.Client : Gtk.Application {
           /// Command line option. "Normalization" can also be called
           /// "synchronization".
           N_("Log folder normalization"), null },
-        { OPTION_LOG_NETWORK, 0, 0, GLib.OptionArg.NONE, null,
+        { OPTION_LOG_IMAP, 0, 0, GLib.OptionArg.NONE, null,
           /// Command line option
-          N_("Log network activity"), null },
-        { OPTION_LOG_PERIODIC, 0, 0, GLib.OptionArg.NONE, null,
-          /// Command line option
-          N_("Log periodic activity"), null },
+          N_("Log IMAP messages"), null },
         { OPTION_LOG_REPLAY_QUEUE, 0, 0, GLib.OptionArg.NONE, null,
           /// Command line option. The IMAP replay queue is how changes
           /// on the server are replicated on the client.  It could
           /// also be called the IMAP events queue.
           N_("Log IMAP replay queue"), null },
-        { OPTION_LOG_SERIALIZER, 0, 0, GLib.OptionArg.NONE, null,
-          /// Command line option. Serialization is how commands and
-          /// responses are converted into a stream of bytes for
-          /// network transmission
-          N_("Log IMAP network serialization"), null },
+        { OPTION_LOG_SMTP, 0, 0, GLib.OptionArg.NONE, null,
+          /// Command line option
+          N_("Log SMTP messages"), null },
         { OPTION_LOG_SQL, 0, 0, GLib.OptionArg.NONE, null,
           /// Command line option
           N_("Log database queries (generates lots of messages)"), null },
@@ -917,23 +911,41 @@ public class Application.Client : Gtk.Application {
 
         bool activated = false;
 
-        // Logging flags
-        if (options.contains(OPTION_LOG_NETWORK))
-            Geary.Logging.enable_flags(Geary.Logging.Flag.NETWORK);
-        if (options.contains(OPTION_LOG_SERIALIZER))
-            Geary.Logging.enable_flags(Geary.Logging.Flag.SERIALIZER);
-        if (options.contains(OPTION_LOG_REPLAY_QUEUE))
-            Geary.Logging.enable_flags(Geary.Logging.Flag.REPLAY);
-        if (options.contains(OPTION_LOG_CONVERSATIONS))
-            Geary.Logging.enable_flags(Geary.Logging.Flag.CONVERSATIONS);
-        if (options.contains(OPTION_LOG_PERIODIC))
-            Geary.Logging.enable_flags(Geary.Logging.Flag.PERIODIC);
-        if (options.contains(OPTION_LOG_SQL))
-            Geary.Logging.enable_flags(Geary.Logging.Flag.SQL);
-        if (options.contains(OPTION_LOG_FOLDER_NORM))
-            Geary.Logging.enable_flags(Geary.Logging.Flag.FOLDER_NORMALIZATION);
-        if (options.contains(OPTION_LOG_DESERIALIZER))
-            Geary.Logging.enable_flags(Geary.Logging.Flag.DESERIALIZER);
+        // Suppress some noisy domains from third-party libraries
+        Geary.Logging.suppress_domain("GdkPixbuf");
+        Geary.Logging.suppress_domain("GLib-Net");
+
+        // Suppress the engine's sub-domains that are extremely
+        // verbose by default unless requested not to do so
+        if (!options.contains(OPTION_LOG_CONVERSATIONS)) {
+            Geary.Logging.suppress_domain(
+                Geary.App.ConversationMonitor.LOGGING_DOMAIN
+            );
+        }
+        if (!options.contains(OPTION_LOG_DESERIALIZER)) {
+            Geary.Logging.suppress_domain(
+                Geary.Imap.ClientService.DESERIALISATION_LOGGING_DOMAIN
+            );
+        }
+        if (!options.contains(OPTION_LOG_IMAP)) {
+            Geary.Logging.suppress_domain(
+                Geary.Imap.ClientService.PROTOCOL_LOGGING_DOMAIN
+            );
+        }
+        if (!options.contains(OPTION_LOG_REPLAY_QUEUE)) {
+            Geary.Logging.suppress_domain(
+                Geary.Imap.ClientService.REPLAY_QUEUE_LOGGING_DOMAIN
+            );
+        }
+        if (!options.contains(OPTION_LOG_SMTP)) {
+            Geary.Logging.suppress_domain(
+                Geary.Smtp.ClientService.PROTOCOL_LOGGING_DOMAIN
+            );
+        }
+        if (!options.contains(OPTION_LOG_SQL)) {
+            Geary.Logging.suppress_domain(Geary.Db.Context.LOGGING_DOMAIN);
+        }
+
         if (options.contains(OPTION_HIDDEN)) {
             warning(
                 /// Warning printed to the console when a deprecated
diff --git a/src/console/main.vala b/src/console/main.vala
index fcb6a320..70e961f8 100644
--- a/src/console/main.vala
+++ b/src/console/main.vala
@@ -661,7 +661,6 @@ void main(string[] args) {
     Gtk.init(ref args);
 
     Geary.Logging.init();
-    Geary.Logging.enable_flags(Geary.Logging.Flag.NETWORK);
     Geary.Logging.log_to(stdout);
 
     ImapConsole console = new ImapConsole();
diff --git a/src/engine/api/geary-account.vala b/src/engine/api/geary-account.vala
index c2d65d90..0a234e28 100644
--- a/src/engine/api/geary-account.vala
+++ b/src/engine/api/geary-account.vala
@@ -255,11 +255,6 @@ public abstract class Geary.Account : BaseObject, Logging.Source {
     public signal void email_flags_changed(Geary.Folder folder,
         Gee.Map<Geary.EmailIdentifier, Geary.EmailFlags> map);
 
-    /** {@inheritDoc} */
-    public Logging.Flag logging_flags {
-        get; protected set; default = Logging.Flag.ALL;
-    }
-
     /** {@inheritDoc} */
     public Logging.Source? logging_parent { get { return null; } }
 
diff --git a/src/engine/api/geary-client-service.vala b/src/engine/api/geary-client-service.vala
index 175e105d..87a6d59e 100644
--- a/src/engine/api/geary-client-service.vala
+++ b/src/engine/api/geary-client-service.vala
@@ -197,11 +197,6 @@ public abstract class Geary.ClientService : BaseObject, Logging.Source {
     /** The last reported error, if any. */
     public ErrorContext? last_error { get; private set; default = null; }
 
-    /** {@inheritDoc} */
-    public override Logging.Flag logging_flags {
-        get; protected set; default = Logging.Flag.ALL;
-    }
-
     /** {@inheritDoc} */
     // XXX see GNOME/vala#119 for why this is necessary
     public virtual string logging_domain {
diff --git a/src/engine/api/geary-folder.vala b/src/engine/api/geary-folder.vala
index e7069766..f98cc504 100644
--- a/src/engine/api/geary-folder.vala
+++ b/src/engine/api/geary-folder.vala
@@ -292,11 +292,6 @@ public abstract class Geary.Folder : BaseObject, Logging.Source {
     /** Monitor for notifying of progress when opening the folder. */
     public abstract Geary.ProgressMonitor opening_monitor { get; }
 
-    /** {@inheritDoc} */
-    public Logging.Flag logging_flags {
-        get; protected set; default = Logging.Flag.ALL;
-    }
-
     /** {@inheritDoc} */
     public Logging.Source? logging_parent {
         get { return this.account; }
diff --git a/src/engine/api/geary-logging.vala b/src/engine/api/geary-logging.vala
index d0f8b349..435069ca 100644
--- a/src/engine/api/geary-logging.vala
+++ b/src/engine/api/geary-logging.vala
@@ -20,92 +20,6 @@ public const string DOMAIN = "Geary";
 /** Specifies the default number of log records retained. */
 public const uint DEFAULT_MAX_LOG_BUFFER_LENGTH = 4096;
 
-/**
- * Denotes a type of log message.
- *
- * Logging for each type of log message may be dynamically enabled or
- * disabled at run time by {@link enable_flags} and {@link
- * disable_flags}.
- */
-[Flags]
-public enum Flag {
-    NONE = 0,
-    NETWORK,
-    SERIALIZER,
-    REPLAY,
-    CONVERSATIONS,
-    PERIODIC,
-    SQL,
-    FOLDER_NORMALIZATION,
-    DESERIALIZER,
-    ALL = int.MAX;
-
-    public inline bool is_all_set(Flag flags) {
-        return (flags & this) == flags;
-    }
-
-    public inline bool is_any_set(Flag flags) {
-        return (flags & this) != 0;
-    }
-
-    public string to_string() {
-        GLib.StringBuilder buf = new GLib.StringBuilder();
-        if (this == ALL) {
-            buf.append("ALL");
-        } else if (this == NONE) {
-            buf.append("NONE");
-        } else {
-            if (this.is_any_set(NETWORK)) {
-                buf.append("NET");
-            }
-            if (this.is_any_set(SERIALIZER)) {
-                if (buf.len > 0) {
-                    buf.append_c('|');
-                }
-                buf.append("SER");
-            }
-            if (this.is_any_set(REPLAY)) {
-                if (buf.len > 0) {
-                    buf.append_c('|');
-                }
-                buf.append("REP");
-            }
-            if (this.is_any_set(CONVERSATIONS)) {
-                if (buf.len > 0) {
-                    buf.append_c('|');
-                }
-                buf.append("CNV");
-            }
-            if (this.is_any_set(PERIODIC)) {
-                if (buf.len > 0) {
-                    buf.append_c('|');
-                }
-                buf.append("PER");
-            }
-            if (this.is_any_set(SQL)) {
-                if (buf.len > 0) {
-                    buf.append_c('|');
-                }
-                buf.append("SQL");
-            }
-            if (this.is_any_set(FOLDER_NORMALIZATION)) {
-                if (buf.len > 0) {
-                    buf.append_c('|');
-                }
-                buf.append("NRM");
-            }
-            if (this.is_any_set(DESERIALIZER)) {
-                if (buf.len > 0) {
-                    buf.append_c('|');
-                }
-                buf.append("DES");
-            }
-        }
-        return buf.str;
-    }
-
-}
-
 /**
  * A record of a single message sent to the logging system.
  *
@@ -129,9 +43,6 @@ public class Record {
     /** Folder from which the record originated, if any. */
     public Folder? folder { get; private set; default = null; }
 
-    /** The logged flags, if any. */
-    public Flag? flags = null;
-
     /** The logged message, if any. */
     public string? message = null;
 
@@ -179,10 +90,6 @@ public class Record {
                     ((Source) field.value).to_logging_state();
                 break;
 
-            case "GEARY_FLAGS":
-                this.flags = (Flag) field.value;
-                break;
-
             case "GLIB_DOMAIN":
                 this.domain = field_to_string(field);
                 break;
@@ -219,7 +126,6 @@ public class Record {
         this.account = other.account;
         this.service = other.service;
         this.folder = other.folder;
-        this.flags = other.flags;
         this.message = other.message;
         this.source_filename = other.source_filename;
         this.source_line_number = other.source_line_number;
@@ -266,7 +172,6 @@ public class Record {
         fill_well_known_sources();
 
         string domain = this.domain ?? "[no domain]";
-        Flag flags = this.flags ?? Flag.NONE;
         string message = this.message ?? "[no message]";
         double float_secs = this.timestamp / 1000.0 / 1000.0;
         double floor_secs = GLib.Math.floor(float_secs);
@@ -276,7 +181,7 @@ public class Record {
         ).to_local();
         GLib.StringBuilder str = new GLib.StringBuilder.sized(128);
         str.printf(
-            "%s %02d:%02d:%02d.%04d %s",
+            "%s %02d:%02d:%02d.%04d %s:",
             to_prefix(levels),
             time.get_hour(),
             time.get_minute(),
@@ -285,12 +190,6 @@ public class Record {
             domain
         );
 
-        if (flags != NONE) {
-            str.append_printf("[%s]:", flags.to_string());
-        } else {
-            str.append(":");
-        }
-
         // Append in reverse so inner sources appear first
         for (int i = this.states.length - 1; i >= 0; i--) {
             str.append(" [");
@@ -333,7 +232,6 @@ public class Record {
 public delegate void LogRecord(Record record);
 
 private int init_count = 0;
-private Flag logging_flags = Flag.NONE;
 
 // The two locks below can't be nullable. See
 // https://gitlab.gnome.org/GNOME/vala/issues/812
@@ -398,95 +296,11 @@ public void clear() {
     }
 }
 
-/**
- * Replaces the current logging flags with flags.  Use Geary.Logging.Flag.NONE to clear all
- * logging flags.
- */
-public void set_flags(Flag flags) {
-    logging_flags = flags;
-}
-
-/**
- * Adds the supplied flags to the current logging flags without disturbing the others.
- */
-public void enable_flags(Flag flags) {
-    logging_flags |= flags;
-}
-
-/**
- * Removes the supplied flags from the current logging flags without disturbing the others.
- */
-public void disable_flags(Flag flags) {
-    logging_flags &= ~flags;
-}
-
 /** Sets a function to be called when a new log record is created. */
 public void set_log_listener(LogRecord? new_listener) {
     listener = new_listener;
 }
 
-
-/**
- * Returns the current logging flags.
- */
-public Flag get_flags() {
-    return logging_flags;
-}
-
-/**
- * Returns true if all the flag(s) are set.
- */
-public inline bool are_all_flags_set(Flag flags) {
-    return logging_flags.is_all_set(flags);
-}
-
-[PrintfFormat]
-public inline void error(Flag flags, string fmt, ...) {
-    logv(flags, GLib.LogLevelFlags.LEVEL_ERROR, fmt, va_list());
-}
-
-[PrintfFormat]
-public inline void critical(Flag flags, string fmt, ...) {
-    logv(flags, GLib.LogLevelFlags.LEVEL_CRITICAL, fmt, va_list());
-}
-
-[PrintfFormat]
-public inline void warning(Flag flags, string fmt, ...) {
-    logv(flags, GLib.LogLevelFlags.LEVEL_WARNING, fmt, va_list());
-}
-
-[PrintfFormat]
-public inline void message(Flag flags, string fmt, ...) {
-    logv(flags, GLib.LogLevelFlags.LEVEL_MESSAGE, fmt, va_list());
-}
-
-[PrintfFormat]
-public inline void debug(Flag flags, string fmt, ...) {
-    logv(flags, GLib.LogLevelFlags.LEVEL_DEBUG, fmt, va_list());
-}
-
-public inline void logv(Flag flags,
-                        GLib.LogLevelFlags level,
-                        string fmt,
-                        va_list args) {
-    if (flags == ALL || logging_flags.is_any_set(flags)) {
-        GLib.log_structured_array(
-            level,
-            new GLib.LogField[] {
-                GLib.LogField<string>() {
-                    key = "GLIB_DOMAIN", value = DOMAIN, length = -1
-                },
-                GLib.LogField<Flag>() {
-                    key = "GEARY_FLAGS", value = flags, length = 0
-                },
-                GLib.LogField<string>() {
-                    key = "MESSAGE", value = fmt.vprintf(args), length = -1
-                }
-            }
-        );
-    }
-}
-
 /** Returns the oldest log record in the logging system's buffer. */
 public Record? get_earliest_record() {
     return first_record;
diff --git a/src/engine/app/app-conversation-monitor.vala b/src/engine/app/app-conversation-monitor.vala
index 65d410bf..644605d4 100644
--- a/src/engine/app/app-conversation-monitor.vala
+++ b/src/engine/app/app-conversation-monitor.vala
@@ -123,11 +123,6 @@ public class Geary.App.ConversationMonitor : BaseObject, Logging.Source {
         get; private set; default = new SimpleProgressMonitor(ProgressType.ACTIVITY);
     }
 
-    /** {@inheritDoc} */
-    public Logging.Flag logging_flags {
-        get; protected set; default = Logging.Flag.CONVERSATIONS;
-    }
-
     /** {@inheritDoc} */
     public override string logging_domain {
         get { return LOGGING_DOMAIN; }
diff --git a/src/engine/app/conversation-monitor/app-conversation-set.vala 
b/src/engine/app/conversation-monitor/app-conversation-set.vala
index c50a382d..8b5c8a0d 100644
--- a/src/engine/app/conversation-monitor/app-conversation-set.vala
+++ b/src/engine/app/conversation-monitor/app-conversation-set.vala
@@ -26,11 +26,6 @@ private class Geary.App.ConversationSet : BaseObject, Logging.Source {
         owned get { return _conversations.read_only_view; }
     }
 
-    /** {@inheritDoc} */
-    public Logging.Flag logging_flags {
-        get; protected set; default = Logging.Flag.CONVERSATIONS;
-    }
-
     /** {@inheritDoc} */
     public override string logging_domain {
         get { return ConversationMonitor.LOGGING_DOMAIN; }
diff --git a/src/engine/db/db-context.vala b/src/engine/db/db-context.vala
index e659d6d4..c1049139 100644
--- a/src/engine/db/db-context.vala
+++ b/src/engine/db/db-context.vala
@@ -18,11 +18,6 @@ public abstract class Geary.Db.Context : BaseObject, Logging.Source {
     /** The GLib logging domain used by this class. */
     public const string LOGGING_DOMAIN = Logging.DOMAIN + ".Db";
 
-    /** {@inheritDoc} */
-    public Logging.Flag logging_flags {
-        get; protected set; default = Logging.Flag.SQL;
-    }
-
     /** {@inheritDoc} */
     public override string logging_domain {
         get { return LOGGING_DOMAIN; }
@@ -68,9 +63,6 @@ public abstract class Geary.Db.Context : BaseObject, Logging.Source {
 
     [PrintfFormat]
     protected void log(string fmt, ...) {
-        if (!Logging.are_all_flags_set(Logging.Flag.SQL))
-            return;
-
         Statement? stmt = get_statement();
         if (stmt != null) {
             debug("%s\n\t<%s>",
diff --git a/src/engine/imap-engine/imap-engine-account-operation.vala 
b/src/engine/imap-engine/imap-engine-account-operation.vala
index 3dc32d37..57505f22 100644
--- a/src/engine/imap-engine/imap-engine-account-operation.vala
+++ b/src/engine/imap-engine/imap-engine-account-operation.vala
@@ -36,11 +36,6 @@
 public abstract class Geary.ImapEngine.AccountOperation : BaseObject, Logging.Source {
 
 
-    /** {@inheritDoc} */
-    public Logging.Flag logging_flags {
-        get; protected set; default = Logging.Flag.ALL;
-    }
-
     /** {@inheritDoc} */
     public Logging.Source? logging_parent { get { return account; } }
 
diff --git a/src/engine/imap-engine/imap-engine-account-processor.vala 
b/src/engine/imap-engine/imap-engine-account-processor.vala
index 9375cf2c..44e0353f 100644
--- a/src/engine/imap-engine/imap-engine-account-processor.vala
+++ b/src/engine/imap-engine/imap-engine-account-processor.vala
@@ -39,11 +39,6 @@ internal class Geary.ImapEngine.AccountProcessor :
     /** Fired when an error occurs processing an operation. */
     public signal void operation_error(AccountOperation op, Error error);
 
-    /** {@inheritDoc} */
-    public Logging.Flag logging_flags {
-        get; protected set; default = Logging.Flag.ALL;
-    }
-
     /** {@inheritDoc} */
     public Logging.Source? logging_parent { get { return _logging_parent; } }
     private weak Logging.Source? _logging_parent = null;
diff --git a/src/engine/imap-engine/imap-engine-account-synchronizer.vala 
b/src/engine/imap-engine/imap-engine-account-synchronizer.vala
index 5d399f24..1880b150 100644
--- a/src/engine/imap-engine/imap-engine-account-synchronizer.vala
+++ b/src/engine/imap-engine/imap-engine-account-synchronizer.vala
@@ -29,11 +29,6 @@ private class Geary.ImapEngine.AccountSynchronizer :
         this.account.folders_contents_altered.connect(on_folders_contents_altered);
     }
 
-    /** {@inheritDoc} */
-    public Logging.Flag logging_flags {
-        get; protected set; default = Logging.Flag.ALL;
-    }
-
     /** {@inheritDoc} */
     public Logging.Source? logging_parent {
         get { return this.account; }
diff --git a/src/engine/imap-engine/imap-engine-replay-queue.vala 
b/src/engine/imap-engine/imap-engine-replay-queue.vala
index 121baafc..103900bd 100644
--- a/src/engine/imap-engine/imap-engine-replay-queue.vala
+++ b/src/engine/imap-engine/imap-engine-replay-queue.vala
@@ -97,11 +97,6 @@ private class Geary.ImapEngine.ReplayQueue : BaseObject, Logging.Source {
         return remote_queue.size;
     } }
 
-    /** {@inheritDoc} */
-    public Logging.Flag logging_flags {
-        get; protected set; default = Logging.Flag.CONVERSATIONS;
-    }
-
     /** {@inheritDoc} */
     public override string logging_domain {
         get { return Imap.ClientService.REPLAY_QUEUE_LOGGING_DOMAIN; }
diff --git a/src/engine/imap/api/imap-session-object.vala b/src/engine/imap/api/imap-session-object.vala
index 33365b06..4937d462 100644
--- a/src/engine/imap/api/imap-session-object.vala
+++ b/src/engine/imap/api/imap-session-object.vala
@@ -23,11 +23,6 @@ public abstract class Geary.Imap.SessionObject : BaseObject, Logging.Source {
     /** Determines if this object has a valid session or not. */
     public bool is_valid { get { return this.session != null; } }
 
-    /** {@inheritDoc} */
-    public Logging.Flag logging_flags {
-        get; protected set; default = Logging.Flag.ALL;
-    }
-
     /** {@inheritDoc} */
     public Logging.Source? logging_parent { get { return _logging_parent; } }
     private weak Logging.Source? _logging_parent = null;
diff --git a/src/engine/imap/transport/imap-client-connection.vala 
b/src/engine/imap/transport/imap-client-connection.vala
index 31cee9bc..ab8f8dc8 100644
--- a/src/engine/imap/transport/imap-client-connection.vala
+++ b/src/engine/imap/transport/imap-client-connection.vala
@@ -54,11 +54,6 @@ public class Geary.Imap.ClientConnection : BaseObject, Logging.Source {
     public bool idle_when_quiet { get; private set; default = false; }
 
 
-    /** {@inheritDoc} */
-    public Logging.Flag logging_flags {
-        get; protected set; default = Logging.Flag.NETWORK;
-    }
-
     /** {@inheritDoc} */
     public override string logging_domain {
         get { return ClientService.PROTOCOL_LOGGING_DOMAIN; }
diff --git a/src/engine/imap/transport/imap-client-session.vala 
b/src/engine/imap/transport/imap-client-session.vala
index 42236ff6..a7c1ae53 100644
--- a/src/engine/imap/transport/imap-client-session.vala
+++ b/src/engine/imap/transport/imap-client-session.vala
@@ -258,11 +258,6 @@ public class Geary.Imap.ClientSession : BaseObject, Logging.Source {
      */
     public bool selected_readonly = false;
 
-    /** {@inheritDoc} */
-    public Logging.Flag logging_flags {
-        get; protected set; default = Logging.Flag.ALL;
-    }
-
     /** {@inheritDoc} */
     public override string logging_domain {
         get { return ClientService.LOGGING_DOMAIN; }
@@ -1234,7 +1229,7 @@ public class Geary.Imap.ClientSession : BaseObject, Logging.Source {
         keepalive_id = 0;
 
         send_command_async.begin(new NoopCommand(), null, on_keepalive_completed);
-        log(PERIODIC, LEVEL_DEBUG, "Sending keepalive...");
+        debug("Sending keepalive...");
 
         // No need to reschedule keepalive, as the notification that the command was sent should
         // do that automatically
@@ -1246,7 +1241,7 @@ public class Geary.Imap.ClientSession : BaseObject, Logging.Source {
         try {
             send_command_async.end(result);
         } catch (GLib.Error err) {
-            log(PERIODIC, LEVEL_WARNING, "Keepalive error: %s", err.message);
+            warning("Keepalive error: %s", err.message);
         }
     }
 
diff --git a/src/engine/imap/transport/imap-deserializer.vala 
b/src/engine/imap/transport/imap-deserializer.vala
index 00a2cf92..bf45c81d 100644
--- a/src/engine/imap/transport/imap-deserializer.vala
+++ b/src/engine/imap/transport/imap-deserializer.vala
@@ -75,11 +75,6 @@ public class Geary.Imap.Deserializer : BaseObject, Logging.Source {
         "Geary.Imap.Deserializer", State.TAG, State.COUNT, Event.COUNT,
         state_to_string, event_to_string);
 
-    /** {@inheritDoc} */
-    public Logging.Flag logging_flags {
-        get; protected set; default = Logging.Flag.DESERIALIZER;
-    }
-
     /** {@inheritDoc} */
     public override string logging_domain {
         get { return ClientService.DESERIALISATION_LOGGING_DOMAIN; }
diff --git a/src/engine/smtp/smtp-client-connection.vala b/src/engine/smtp/smtp-client-connection.vala
index fefd8ce0..bc0e9310 100644
--- a/src/engine/smtp/smtp-client-connection.vala
+++ b/src/engine/smtp/smtp-client-connection.vala
@@ -20,11 +20,6 @@ internal class Geary.Smtp.ClientConnection : BaseObject, Logging.Source {
         get { return ClientService.PROTOCOL_LOGGING_DOMAIN; }
     }
 
-    /** {@inheritDoc} */
-    public Logging.Flag logging_flags {
-        get; protected set; default = Logging.Flag.ALL;
-    }
-
     /** {@inheritDoc} */
     public Logging.Source? logging_parent { get { return _logging_parent; } }
     private weak Logging.Source? _logging_parent = null;
diff --git a/src/engine/smtp/smtp-client-session.vala b/src/engine/smtp/smtp-client-session.vala
index f22d90a5..9e60a624 100644
--- a/src/engine/smtp/smtp-client-session.vala
+++ b/src/engine/smtp/smtp-client-session.vala
@@ -14,11 +14,6 @@ public class Geary.Smtp.ClientSession : BaseObject, Logging.Source {
         get { return ClientService.LOGGING_DOMAIN; }
     }
 
-    /** {@inheritDoc} */
-    public Logging.Flag logging_flags {
-        get; protected set; default = Logging.Flag.ALL;
-    }
-
     /** {@inheritDoc} */
     public Logging.Source? logging_parent { get { return _logging_parent; } }
     private weak Logging.Source? _logging_parent = null;
diff --git a/src/engine/util/util-logging.vala b/src/engine/util/util-logging.vala
index 5fd90403..13f9763b 100644
--- a/src/engine/util/util-logging.vala
+++ b/src/engine/util/util-logging.vala
@@ -107,7 +107,6 @@ public interface Geary.Logging.Source : GLib.Object {
 
 
         Context(string domain,
-                Logging.Flag flags,
                 GLib.LogLevelFlags level,
                 string message,
                 va_list args) {
@@ -116,7 +115,6 @@ public interface Geary.Logging.Source : GLib.Object {
             this.count = 0;
             append("PRIORITY", log_level_to_priority(level));
             append("GLIB_DOMAIN", domain);
-            append("GEARY_FLAGS", flags);
 
             this.message = message.vprintf(va_list.copy(args));
         }
@@ -156,11 +154,6 @@ public interface Geary.Logging.Source : GLib.Object {
         get { return DOMAIN; }
     }
 
-    /**
-     * Default flags to use for this source when logging messages.
-     */
-    public abstract Logging.Flag logging_flags { get; protected set; }
-
     /**
      * The parent of this source.
      *
@@ -197,9 +190,7 @@ public interface Geary.Logging.Source : GLib.Object {
     [PrintfFormat]
     public inline void debug(string fmt, ...) {
         if (!(this.logging_domain in Logging.suppressed_domains)) {
-            log_structured(
-                this.logging_flags, LogLevelFlags.LEVEL_DEBUG, fmt, va_list()
-            );
+            log_structured(LEVEL_DEBUG, fmt, va_list());
         }
     }
 
@@ -208,9 +199,7 @@ public interface Geary.Logging.Source : GLib.Object {
      */
     [PrintfFormat]
     public inline void message(string fmt, ...) {
-        log_structured(
-            this.logging_flags, LogLevelFlags.LEVEL_MESSAGE, fmt, va_list()
-        );
+        log_structured(LEVEL_MESSAGE, fmt, va_list());
     }
 
     /**
@@ -218,9 +207,7 @@ public interface Geary.Logging.Source : GLib.Object {
      */
     [PrintfFormat]
     public inline void warning(string fmt, ...) {
-        log_structured(
-            this.logging_flags, LogLevelFlags.LEVEL_WARNING, fmt, va_list()
-        );
+        log_structured(LEVEL_WARNING, fmt, va_list());
     }
 
     /**
@@ -229,9 +216,7 @@ public interface Geary.Logging.Source : GLib.Object {
     [PrintfFormat]
     [NoReturn]
     public inline void error(string fmt, ...) {
-        log_structured(
-            this.logging_flags, LogLevelFlags.LEVEL_ERROR, fmt, va_list()
-        );
+        log_structured(LEVEL_ERROR, fmt, va_list());
     }
 
     /**
@@ -239,40 +224,24 @@ public interface Geary.Logging.Source : GLib.Object {
      */
     [PrintfFormat]
     public inline void critical(string fmt, ...) {
-        log_structured(
-            this.logging_flags, LogLevelFlags.LEVEL_CRITICAL, fmt, va_list()
-        );
+        log_structured(LEVEL_CRITICAL, fmt, va_list());
     }
 
-    /**
-     * Logs a message with this object as context.
-     */
-    [PrintfFormat]
-    public inline void log(Logging.Flag flags,
-                           GLib.LogLevelFlags levels,
-                           string fmt, ...) {
-        log_structured(flags, levels, fmt, va_list());
-    }
-
-    private inline void log_structured(Logging.Flag flags,
-                                       GLib.LogLevelFlags levels,
+    private inline void log_structured(GLib.LogLevelFlags levels,
                                        string fmt,
                                        va_list args) {
-        if (flags == ALL || Logging.get_flags().is_any_set(flags)) {
-            Context context = Context(
-                this.logging_domain, flags, levels, fmt, args
-            );
-            // Don't attempt to this object if it is in the middle of
-            // being destructed, which can happen when logging from
-            // the destructor.
-            Source? decorated = (this.ref_count > 0) ? this : this.logging_parent;
-            while (decorated != null) {
-                context.append_source(decorated);
-                decorated = decorated.logging_parent;
-            }
-
-            GLib.log_structured_array(levels, context.to_array());
+        Context context = Context(this.logging_domain, levels, fmt, args);
+
+        // Don't attempt to this object if it is in the middle of
+        // being destructed, which can happen when logging from
+        // the destructor.
+        Source? decorated = (this.ref_count > 0) ? this : this.logging_parent;
+        while (decorated != null) {
+            context.append_source(decorated);
+            decorated = decorated.logging_parent;
         }
+
+        GLib.log_structured_array(levels, context.to_array());
     }
 
 }
diff --git a/src/mailer/main.vala b/src/mailer/main.vala
index 790f2100..aaaca73f 100644
--- a/src/mailer/main.vala
+++ b/src/mailer/main.vala
@@ -159,10 +159,9 @@ int main(string[] args) {
     }
 
     stdout.printf("Enabling debug: %s\n", arg_debug.to_string());
+    Geary.Logging.init();
     if (arg_debug) {
-        Geary.Logging.init();
         Geary.Logging.log_to(stdout);
-        Geary.Logging.enable_flags(Geary.Logging.Flag.NETWORK);
         GLib.Log.set_writer_func(Geary.Logging.default_log_writer);
     }
 
diff --git a/test/test-client.vala b/test/test-client.vala
index 1d32bc2c..6ccd547d 100644
--- a/test/test-client.vala
+++ b/test/test-client.vala
@@ -40,9 +40,7 @@ int main(string[] args) {
     Geary.HTML.init();
     Geary.Logging.init();
     if (GLib.Test.verbose()) {
-        Geary.Logging.enable_flags(ALL);
         GLib.Log.set_writer_func(Geary.Logging.default_log_writer);
-        Geary.Logging.enable_flags(ALL);
         Geary.Logging.log_to(GLib.stdout);
     }
 
diff --git a/test/test-engine.vala b/test/test-engine.vala
index b738e1a7..2edf95c6 100644
--- a/test/test-engine.vala
+++ b/test/test-engine.vala
@@ -23,9 +23,7 @@ int main(string[] args) {
     Geary.HTML.init();
     Geary.Logging.init();
     if (GLib.Test.verbose()) {
-        Geary.Logging.enable_flags(ALL);
         GLib.Log.set_writer_func(Geary.Logging.default_log_writer);
-        Geary.Logging.enable_flags(ALL);
         Geary.Logging.log_to(GLib.stdout);
     }
 


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