[geary/mjog/logging-update: 7/8] Ensure some kind of logging source location is being printed



commit 24a0ad70ae70bdc861653dd989cd8cf78a3f32fa
Author: Michael Gratton <mike vee net>
Date:   Mon Dec 2 18:19:52 2019 +0800

    Ensure some kind of logging source location is being printed
    
    If printing source and line number is not being printed (it isn't at
    the moment) then print the class name of the inner-most logging source
    to give an idea of where the message came from.

 src/engine/api/geary-logging.vala | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/src/engine/api/geary-logging.vala b/src/engine/api/geary-logging.vala
index f5b1e097..07346156 100644
--- a/src/engine/api/geary-logging.vala
+++ b/src/engine/api/geary-logging.vala
@@ -256,21 +256,18 @@ public class Record {
         );
 
         if (flags != NONE) {
-            str.append_printf("[%s]: ", flags.to_string());
+            str.append_printf("[%s]:", flags.to_string());
         } else {
-            str.append(": ");
+            str.append(":");
         }
 
         // Append in reverse so inner sources appear first
         for (int i = this.states.length - 1; i >= 0; i--) {
-            str.append("[");
+            str.append(" [");
             str.append(this.states[i].format_message());
-            str.append("] ");
+            str.append("]");
         }
 
-        str.append(message);
-
-
         // XXX Don't append source details for the moment because of
         // https://gitlab.gnome.org/GNOME/vala/issues/815
         bool disabled = true;
@@ -286,8 +283,17 @@ public class Record {
                 str.append(this.source_function.to_string());
             }
             str.append("]");
+        } else if (this.states.length > 0) {
+            // Print the class name of the leaf logging source to at
+            // least give a general idea of where the message came
+            // from.
+            str.append(" ");
+            str.append(this.states[0].source.get_type().name());
+            str.append(": ");
         }
 
+        str.append(message);
+
         return str.str;
     }
 


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