[gnome-music] log: show real filename and lineno for @log-decorated functions
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] log: show real filename and lineno for @log-decorated functions
- Date: Wed, 15 Jul 2015 11:20:34 +0000 (UTC)
commit e130faa549747529acb76bcc4e934de089bce5b4
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date: Wed Jul 15 13:20:15 2015 +0200
log: show real filename and lineno for @log-decorated functions
gnome-music.in | 4 ++--
gnomemusic/__init__.py | 6 +++++-
2 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/gnome-music.in b/gnome-music.in
index fa930a3..ee88449 100644
--- a/gnome-music.in
+++ b/gnome-music.in
@@ -59,7 +59,7 @@ if __name__ == "__main__":
args = parser.parse_args()
if args.debug:
logging.basicConfig(level=logging.DEBUG,
- format='%(asctime)s %(levelname)s\t%(filename)s:%(lineno)d \t%(message)s',
+ format='%(asctime)s %(levelname)s\t%(message)s',
datefmt='%H:%M:%S')
# Gtk hates "-d" switch, so lets drop it
if '-d' in sys.argv:
@@ -68,7 +68,7 @@ if __name__ == "__main__":
sys.argv.remove("--debug")
else:
logging.basicConfig(level=logging.WARN,
- format='%(asctime)s %(levelname)s\t%(filename)s:%(lineno)d \t%(message)s',
+ format='%(asctime)s %(levelname)s\t%(message)s',
datefmt='%H:%M:%S')
locale.bindtextdomain('gnome-music', localedir)
diff --git a/gnomemusic/__init__.py b/gnomemusic/__init__.py
index c399fc7..035d29f 100644
--- a/gnomemusic/__init__.py
+++ b/gnomemusic/__init__.py
@@ -43,6 +43,9 @@ def log(fn):
global tabbing
name = fn.__name__
module = fn.__module__
+ filename = fn.__code__.co_filename.split('/')[-1]
+ lineno = fn.__code__.co_firstlineno
+
params = ", ".join(map(repr, chain(v, k.values())))
tabbing += 1
@@ -53,7 +56,8 @@ def log(fn):
elapsed_time = ''
if elapsed > 0.5:
elapsed_time = ', took %02f' % elapsed
- logger.debug("%s%s.%s(%s), returned %s%s", '|' * tabbing, module, name, params, retval, elapsed_time)
+ logger.debug("%s:%s %s%s.%s(%s), returned %s%s",
+ filename, lineno, '|' * tabbing, module, name, params, retval, elapsed_time)
return retval
return wrapped
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]