[geary/mjog/misc-criticals: 4/9] Geary.Util.Logging: Respect standard G_DEBUG breakpoint semantics



commit 997e8e2c4d2abd6a70d2298c3b0442467c7b3b73
Author: Michael Gratton <mike vee net>
Date:   Fri Jun 26 17:15:12 2020 +1000

    Geary.Util.Logging: Respect standard G_DEBUG breakpoint semantics
    
    Check the value of G_DEBUG and ensure we trip gdb breakpoint as
    appropriate for warnings and criticals.

 src/engine/util/util-logging.vala | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
---
diff --git a/src/engine/util/util-logging.vala b/src/engine/util/util-logging.vala
index acfdc97d3..c0356862a 100644
--- a/src/engine/util/util-logging.vala
+++ b/src/engine/util/util-logging.vala
@@ -54,6 +54,7 @@ namespace Geary.Logging {
     private GLib.Mutex writer_lock;
     private unowned FileStream? stream = null;
 
+    private GLib.LogLevelFlags set_breakpoint_on = 0;
     private Gee.Set<string> suppressed_domains;
 
 
@@ -71,6 +72,18 @@ namespace Geary.Logging {
             Logging.record_lock = GLib.Mutex();
             Logging.writer_lock = GLib.Mutex();
             Logging.max_log_length = DEFAULT_MAX_LOG_BUFFER_LENGTH;
+
+            var debug_var = GLib.Environment.get_variable("G_DEBUG");
+            if (debug_var != null) {
+                var parts = debug_var.split(",");
+                if ("fatal-warnings" in parts) {
+                    Logging.set_breakpoint_on |= GLib.LogLevelFlags.LEVEL_WARNING;
+                }
+                if ("fatal-criticals" in parts) {
+                    Logging.set_breakpoint_on |= GLib.LogLevelFlags.LEVEL_WARNING;
+                    Logging.set_breakpoint_on |= GLib.LogLevelFlags.LEVEL_CRITICAL;
+                }
+            }
         }
     }
 
@@ -299,6 +312,10 @@ namespace Geary.Logging {
             out.puts(record.format());
             out.putc('\n');
             Logging.writer_lock.unlock();
+
+            if (levels in Logging.set_breakpoint_on) {
+                GLib.breakpoint();
+            }
         }
     }
 


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