[geary/mjog/logging-update: 1/8] Rename Geary.Loggable to Geary.Logging.Source



commit 978ff12810cf175a14815952f36fb67a91ba9479
Author: Michael Gratton <mike vee net>
Date:   Sun Dec 1 19:37:15 2019 +1100

    Rename Geary.Loggable to Geary.Logging.Source
    
    Rename the class because we need to distinguish between logging sources
    and logging state, for cases when the logged object's state may change
    between being logged and being displayed.
    
    Rename util souce file to match new name space per source code
    convernstion.

 po/POTFILES.in                                     |  2 +-
 .../components/components-inspector-log-view.vala  |  2 +-
 src/engine/api/geary-account.vala                  |  6 +--
 src/engine/api/geary-client-service.vala           | 12 ++---
 src/engine/api/geary-folder.vala                   |  6 +--
 src/engine/api/geary-logging.vala                  | 54 +++++++++++-----------
 .../imap-engine/imap-engine-account-operation.vala |  6 +--
 .../imap-engine/imap-engine-generic-account.vala   |  4 +-
 src/engine/meson.build                             |  2 +-
 .../util/{util-loggable.vala => util-logging.vala} | 38 +++++++--------
 10 files changed, 67 insertions(+), 65 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index c4b1b920..5ec9b69e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -396,7 +396,7 @@ src/engine/util/util-idle-manager.vala
 src/engine/util/util-imap-utf7.vala
 src/engine/util/util-inet.vala
 src/engine/util/util-iterable.vala
-src/engine/util/util-loggable.vala
+src/engine/util/util-logging.vala
 src/engine/util/util-numeric.vala
 src/engine/util/util-object.vala
 src/engine/util/util-reference-semantics.vala
diff --git a/src/client/components/components-inspector-log-view.vala 
b/src/client/components/components-inspector-log-view.vala
index e09649af..c1e3d996 100644
--- a/src/client/components/components-inspector-log-view.vala
+++ b/src/client/components/components-inspector-log-view.vala
@@ -214,7 +214,7 @@ public class Components.InspectorLogView : Gtk.Grid {
         // Blacklist GdkPixbuf since it spams us e.g. when window
         // focus changes, including between MainWindow and the
         // Inspector, which is very annoying.
-        record.fill_well_known_loggables();
+        record.fill_well_known_sources();
         return (
             record.domain != "GdkPixbuf" &&
             (record.account == null ||
diff --git a/src/engine/api/geary-account.vala b/src/engine/api/geary-account.vala
index e5a0fbd5..e4223cf7 100644
--- a/src/engine/api/geary-account.vala
+++ b/src/engine/api/geary-account.vala
@@ -22,7 +22,7 @@
  * A list of all Accounts may be retrieved from the {@link Engine} singleton.
  */
 
-public abstract class Geary.Account : BaseObject, Loggable {
+public abstract class Geary.Account : BaseObject, Logging.Source {
 
 
     /** Number of times to attempt re-authentication. */
@@ -247,12 +247,12 @@ public abstract class Geary.Account : BaseObject, Loggable {
         Gee.Map<Geary.EmailIdentifier, Geary.EmailFlags> map);
 
     /** {@inheritDoc} */
-    public Logging.Flag loggable_flags {
+    public Logging.Flag logging_flags {
         get; protected set; default = Logging.Flag.ALL;
     }
 
     /** {@inheritDoc} */
-    public Loggable? loggable_parent { get { return null; } }
+    public Logging.Source? logging_parent { get { return null; } }
 
 
     protected Account(AccountInformation information,
diff --git a/src/engine/api/geary-client-service.vala b/src/engine/api/geary-client-service.vala
index 6f6da006..c9dbcf29 100644
--- a/src/engine/api/geary-client-service.vala
+++ b/src/engine/api/geary-client-service.vala
@@ -14,7 +14,7 @@
  * itself, rather manages the configuration, status tracking, and
  * life-cycle of concrete implementations.
  */
-public abstract class Geary.ClientService : BaseObject, Loggable {
+public abstract class Geary.ClientService : BaseObject, Logging.Source {
 
 
     private const int BECAME_REACHABLE_TIMEOUT_SEC = 1;
@@ -198,13 +198,13 @@ public abstract class Geary.ClientService : BaseObject, Loggable {
     public ErrorContext? last_error { get; private set; default = null; }
 
     /** {@inheritDoc} */
-    public Logging.Flag loggable_flags {
+    public Logging.Flag logging_flags {
         get; protected set; default = Logging.Flag.ALL;
     }
 
     /** {@inheritDoc} */
-    public Loggable? loggable_parent { get { return _loggable_parent; } }
-    private weak Loggable? _loggable_parent = null;
+    public Logging.Source? logging_parent { get { return _logging_parent; } }
+    private weak Logging.Source? _logging_parent = null;
 
 
     protected ClientService(AccountInformation account,
@@ -301,8 +301,8 @@ public abstract class Geary.ClientService : BaseObject, Loggable {
     }
 
     /** Sets the service's logging parent. */
-    internal void set_loggable_parent(Loggable parent) {
-        this._loggable_parent = parent;
+    internal void set_logging_parent(Logging.Source parent) {
+        this._logging_parent = parent;
     }
 
     /**
diff --git a/src/engine/api/geary-folder.vala b/src/engine/api/geary-folder.vala
index a7f4d7fe..a7aeb632 100644
--- a/src/engine/api/geary-folder.vala
+++ b/src/engine/api/geary-folder.vala
@@ -61,7 +61,7 @@
  *
  * @see Geary.SpecialFolderType
  */
-public abstract class Geary.Folder : BaseObject, Loggable {
+public abstract class Geary.Folder : BaseObject, Logging.Source {
 
     /**
      * Indicates if a folder has been opened, and if so in which way.
@@ -239,12 +239,12 @@ public abstract class Geary.Folder : BaseObject, Loggable {
     public abstract Geary.ProgressMonitor opening_monitor { get; }
 
     /** {@inheritDoc} */
-    public Logging.Flag loggable_flags {
+    public Logging.Flag logging_flags {
         get; protected set; default = Logging.Flag.ALL;
     }
 
     /** {@inheritDoc} */
-    public Loggable? loggable_parent {
+    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 bdbe8744..146b58a5 100644
--- a/src/engine/api/geary-logging.vala
+++ b/src/engine/api/geary-logging.vala
@@ -153,7 +153,7 @@ public class Record {
     /** The next log record in the buffer, if any. */
     public Record? next { get; internal set; default = null; }
 
-    private Loggable[] loggables;
+    private Source[] sources;
     private bool filled = false;
     private bool old_log_api = false;
 
@@ -170,12 +170,12 @@ public class Record {
 
         // Since GLib.LogField only retains a weak ref to its value,
         // find and ref any values we wish to keep around.
-        this.loggables = new Loggable[fields.length];
-        int loggable_count = 0;
+        this.sources = new Source[fields.length];
+        int source_count = 0;
         foreach (GLib.LogField field in fields) {
             switch (field.key) {
-            case "GEARY_LOGGABLE":
-                this.loggables[loggable_count++] = (Loggable) field.value;
+            case "GEARY_LOGGING_SOURCE":
+                this.sources[source_count++] = (Source) field.value;
                 break;
 
             case "GEARY_FLAGS":
@@ -204,20 +204,20 @@ public class Record {
             }
         }
 
-        this.loggables.length = loggable_count;
+        this.sources.length = source_count;
     }
 
-    /** Returns the record's loggables that aren't well-known. */
-    public Loggable[] get_other_loggables() {
-        fill_well_known_loggables();
+    /** Returns the record's sources that aren't well-known. */
+    public Source[] get_other_sources() {
+        fill_well_known_sources();
 
-        Loggable[] copy = new Loggable[this.loggables.length];
+        Source[] copy = new Source[this.sources.length];
         int count = 0;
-        foreach (Loggable loggable in this.loggables) {
-            if (loggable != this.account &&
-                loggable != this.service &&
-                loggable != this.folder) {
-                copy[count++] = loggable;
+        foreach (Source source in this.sources) {
+            if (source != this.account &&
+                source != this.service &&
+                source != this.folder) {
+                copy[count++] = source;
             }
         }
         copy.length = count;
@@ -225,22 +225,22 @@ public class Record {
     }
 
     /**
-     * Sets the well-known loggable properties.
+     * Sets the well-known logging source properties.
      *
      * Call this before trying to access {@link account}, {@link
      * folder} and {@link service}. Determining these can be
      * computationally complex and hence is not done by default.
      */
-    public void fill_well_known_loggables() {
+    public void fill_well_known_sources() {
         if (!this.filled) {
-            foreach (Loggable loggable in this.loggables) {
-                GLib.Type type = loggable.get_type();
+            foreach (Source source in this.sources) {
+                GLib.Type type = source.get_type();
                 if (type.is_a(typeof(Account))) {
-                    this.account = (Account) loggable;
+                    this.account = (Account) source;
                 } else if (type.is_a(typeof(ClientService))) {
-                    this.service = (ClientService) loggable;
+                    this.service = (ClientService) source;
                 } else if (type.is_a(typeof(Folder))) {
-                    this.folder = (Folder) loggable;
+                    this.folder = (Folder) source;
                 }
             }
             this.filled = true;
@@ -249,7 +249,7 @@ public class Record {
 
     /** Returns a formatted string representation of this record. */
     public string format() {
-        fill_well_known_loggables();
+        fill_well_known_sources();
 
         string domain = this.domain ?? "[no domain]";
         Flag flags = this.flags ?? Flag.NONE;
@@ -271,7 +271,7 @@ public class Record {
             domain
         );
 
-        if (flags != NONE && flags != ALL) {
+        if (flags != NONE) {
             str.append_printf("[%s]: ", flags.to_string());
         } else {
             str.append(": ");
@@ -299,8 +299,10 @@ public class Record {
             str.append(": ");
         }
 
-        foreach (Loggable loggable in get_other_loggables()) {
-            str.append(loggable.to_string());
+        // Append in reverse so leaf sources appears last
+        var sources = get_other_sources();
+        for (int i = sources.length - 1; i >= 0; i--) {
+            str.append(sources[i].to_string());
             str.append_c(' ');
         }
 
diff --git a/src/engine/imap-engine/imap-engine-account-operation.vala 
b/src/engine/imap-engine/imap-engine-account-operation.vala
index 99a7fdb3..38c4b047 100644
--- a/src/engine/imap-engine/imap-engine-account-operation.vala
+++ b/src/engine/imap-engine/imap-engine-account-operation.vala
@@ -33,16 +33,16 @@
  * equal_to} method to specify which instances are considered to be
  * duplicates.
  */
-public abstract class Geary.ImapEngine.AccountOperation : BaseObject, Loggable {
+public abstract class Geary.ImapEngine.AccountOperation : BaseObject, Logging.Source {
 
 
     /** {@inheritDoc} */
-    public Logging.Flag loggable_flags {
+    public Logging.Flag logging_flags {
         get; protected set; default = Logging.Flag.ALL;
     }
 
     /** {@inheritDoc} */
-    public Loggable? loggable_parent { get { return account; } }
+    public Logging.Source? logging_parent { get { return account; } }
 
     /** The account this operation applies to. */
     protected weak Geary.Account account { get; private set; }
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala 
b/src/engine/imap-engine/imap-engine-generic-account.vala
index b790d647..ae9f0cb2 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -91,12 +91,12 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
         imap.notify["current-status"].connect(
             on_imap_status_notify
         );
-        imap.set_loggable_parent(this);
+        imap.set_logging_parent(this);
         this.imap = imap;
 
         smtp.outbox = new Outbox.Folder(this, local_folder_root, local);
         smtp.report_problem.connect(notify_report_problem);
-        smtp.set_loggable_parent(this);
+        smtp.set_logging_parent(this);
         this.smtp = smtp;
 
         this.sync = new AccountSynchronizer(this);
diff --git a/src/engine/meson.build b/src/engine/meson.build
index 7515ee72..3d83d81e 100644
--- a/src/engine/meson.build
+++ b/src/engine/meson.build
@@ -307,7 +307,7 @@ geary_engine_vala_sources = files(
   'util/util-imap-utf7.vala',
   'util/util-inet.vala',
   'util/util-iterable.vala',
-  'util/util-loggable.vala',
+  'util/util-logging.vala',
   'util/util-numeric.vala',
   'util/util-object.vala',
   'util/util-reference-semantics.vala',
diff --git a/src/engine/util/util-loggable.vala b/src/engine/util/util-logging.vala
similarity index 79%
rename from src/engine/util/util-loggable.vala
rename to src/engine/util/util-logging.vala
index d559f41b..3fac688d 100644
--- a/src/engine/util/util-loggable.vala
+++ b/src/engine/util/util-logging.vala
@@ -8,14 +8,14 @@
 /**
  * Mixin interface for objects that support structured logging.
  *
- * Loggable objects provide both a standard means to obtain a string
+ * Logging sources provide both a standard means to obtain a string
  * representation of the object for display to humans, and keep a weak
- * reference to some parent loggable, enabling this context to be
+ * reference to some parent source, enabling context to be
  * automatically added to logging calls. For example, if a Foo object
- * is the loggable parent of a Bar object, log calls made by Bar will
- * automatically be decorated with Foo.
+ * is the logging source parent of a Bar object, log calls made by Bar
+ * will automatically be decorated with Foo.
  */
-public interface Geary.Loggable : GLib.Object {
+public interface Geary.Logging.Source : GLib.Object {
 
 
     // Based on function from with the same name from GLib's
@@ -87,8 +87,8 @@ public interface Geary.Loggable : GLib.Object {
             this.count++;
         }
 
-        public inline void append_loggable(Loggable value) {
-            this.append("GEARY_LOGGABLE", value);
+        public inline void append_source(Source value) {
+            this.append("GEARY_LOGGING_SOURCE", value);
         }
 
         public GLib.LogField[] to_array() {
@@ -101,17 +101,17 @@ public interface Geary.Loggable : GLib.Object {
 
 
     /**
-     * Default flags to use for this loggable when logging messages.
+     * Default flags to use for this source when logging messages.
      */
-    public abstract Logging.Flag loggable_flags { get; protected set; }
+    public abstract Logging.Flag logging_flags { get; protected set; }
 
     /**
-     * The parent of this loggable.
+     * The parent of this source.
      *
      * If not null, the parent and its ancestors recursively will be
      * added to to log message context.
      */
-    public abstract Loggable? loggable_parent { get; }
+    public abstract Source? logging_parent { get; }
 
     /**
      * Returns a string representation of the service, for debugging.
@@ -125,7 +125,7 @@ public interface Geary.Loggable : GLib.Object {
     [PrintfFormat]
     public inline void debug(string fmt, ...) {
         log_structured(
-            this.loggable_flags, LogLevelFlags.LEVEL_DEBUG, fmt, va_list()
+            this.logging_flags, LogLevelFlags.LEVEL_DEBUG, fmt, va_list()
         );
     }
 
@@ -135,7 +135,7 @@ public interface Geary.Loggable : GLib.Object {
     [PrintfFormat]
     public inline void message(string fmt, ...) {
         log_structured(
-            this.loggable_flags, LogLevelFlags.LEVEL_MESSAGE, fmt, va_list()
+            this.logging_flags, LogLevelFlags.LEVEL_MESSAGE, fmt, va_list()
         );
     }
 
@@ -145,7 +145,7 @@ public interface Geary.Loggable : GLib.Object {
     [PrintfFormat]
     public inline void warning(string fmt, ...) {
         log_structured(
-            this.loggable_flags, LogLevelFlags.LEVEL_WARNING, fmt, va_list()
+            this.logging_flags, LogLevelFlags.LEVEL_WARNING, fmt, va_list()
         );
     }
 
@@ -156,7 +156,7 @@ public interface Geary.Loggable : GLib.Object {
     [NoReturn]
     public inline void error(string fmt, ...) {
         log_structured(
-            this.loggable_flags, LogLevelFlags.LEVEL_ERROR, fmt, va_list()
+            this.logging_flags, LogLevelFlags.LEVEL_ERROR, fmt, va_list()
         );
     }
 
@@ -166,7 +166,7 @@ public interface Geary.Loggable : GLib.Object {
     [PrintfFormat]
     public inline void critical(string fmt, ...) {
         log_structured(
-            this.loggable_flags, LogLevelFlags.LEVEL_CRITICAL, fmt, va_list()
+            this.logging_flags, LogLevelFlags.LEVEL_CRITICAL, fmt, va_list()
         );
     }
 
@@ -175,10 +175,10 @@ public interface Geary.Loggable : GLib.Object {
                                        string fmt,
                                        va_list args) {
         Context context = Context(Logging.DOMAIN, flags, levels, fmt, args);
-        Loggable? decorated = this;
+        Source? decorated = this;
         while (decorated != null) {
-            context.append_loggable(decorated);
-            decorated = decorated.loggable_parent;
+            context.append_source(decorated);
+            decorated = decorated.logging_parent;
         }
 
         GLib.log_structured_array(levels, context.to_array());


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