Commit e130faa5 authored by Vadim Rutkovsky's avatar Vadim Rutkovsky

log: show real filename and lineno for @log-decorated functions

parent 336ca0b1
......@@ -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)
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment