[gnome-music/wip/mschraal/glib-logging] musiclogger: Pass extra fields



commit 34d9049d7ebaf0ecc2a13a400e23b1e28d0342b2
Author: Marinus Schraal <mschraal gnome org>
Date:   Tue Jan 14 16:00:58 2020 +0100

    musiclogger: Pass extra fields

 gnomemusic/musiclogger.py | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/musiclogger.py b/gnomemusic/musiclogger.py
index 2d311b00..6558767a 100644
--- a/gnomemusic/musiclogger.py
+++ b/gnomemusic/musiclogger.py
@@ -22,6 +22,8 @@
 # code, but you are not obligated to do so.  If you do not wish to do so,
 # delete this exception statement from your version.
 
+import inspect
+
 from gi.repository import GObject, GLib
 
 
@@ -35,7 +37,18 @@ class MusicLogger(GObject.GObject):
 
     def _log(self, message, level):
         variant_message = GLib.Variant("s", message)
-        variant_dict = GLib.Variant("a{sv}", {"MESSAGE": variant_message})
+        stack = inspect.stack()
+        variant_file = GLib.Variant("s", stack[2][1])
+        variant_line = GLib.Variant("i", stack[2][2])
+        variant_func = GLib.Variant("s", stack[2][3])
+
+        variant_dict = GLib.Variant("a{sv}", {
+            "MESSAGE": variant_message,
+            "CODE_FILE": variant_file,
+            "CODE_LINE": variant_line,
+            "CODE_FUNC": variant_func
+        })
+
         GLib.log_variant(self._DOMAIN, level, variant_dict)
 
     def message(self, message):


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