[gnome-music/wip/mschraal/glib-logging: 23/23] musiclogger: Enhance debug messages
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/glib-logging: 23/23] musiclogger: Enhance debug messages
- Date: Wed, 15 Jan 2020 09:40:38 +0000 (UTC)
commit 392ae355c63ba7f64ccced07902c61733a83c97f
Author: Marinus Schraal <mschraal gnome org>
Date: Wed Jan 15 10:09:28 2020 +0100
musiclogger: Enhance debug messages
Add filename, function and line of code to debug messages.
gnomemusic/musiclogger.py | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/gnomemusic/musiclogger.py b/gnomemusic/musiclogger.py
index fecf929e..fb465792 100644
--- a/gnomemusic/musiclogger.py
+++ b/gnomemusic/musiclogger.py
@@ -22,7 +22,7 @@
# 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
+import inspect, os
from gi.repository import GObject, GLib
@@ -36,11 +36,20 @@ class MusicLogger(GObject.GObject):
_DOMAIN = "org.gnome.Music"
def _log(self, message, level):
- variant_message = GLib.Variant("s", 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])
+
+ filename = os.path.basename(stack[2][1])
+ line = stack[2][2]
+ function = stack[2][3]
+
+ if level == GLib.LogLevelFlags.LEVEL_DEBUG:
+ message = "({}, {}, {}) {}".format(
+ filename, function, line, message)
+
+ variant_message = GLib.Variant("s", message)
+ variant_file = GLib.Variant("s", filename)
+ variant_line = GLib.Variant("i", line)
+ variant_func = GLib.Variant("s", function)
variant_dict = GLib.Variant("a{sv}", {
"MESSAGE": variant_message,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]