diff options
author | Miklos Vajna <vmiklos@vmiklos.hu> | 2013-03-06 20:56:19 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@vmiklos.hu> | 2013-03-06 20:56:19 +0100 |
commit | 52ceb4b1e90f1b8640e7a232a3fe02b2748ae1b2 (patch) | |
tree | 3406baa5326c3e85ed7d686289667c2813df2c1a | |
parent | 8407e25f982c69d8b2cd01bc5802f3d45fa9dbf1 (diff) |
skyped: prefix debug messages with source location
-rw-r--r-- | protocols/skype/skyped.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/protocols/skype/skyped.py b/protocols/skype/skyped.py index fe35498f..b4617056 100644 --- a/protocols/skype/skyped.py +++ b/protocols/skype/skyped.py @@ -253,13 +253,13 @@ def dprint(msg): from time import strftime global options - now = strftime("%Y-%m-%d %H:%M:%S") - if options.debug: + import inspect + prefix = strftime("[%Y-%m-%d %H:%M:%S]") + " %s:%d" % inspect.stack()[1][1:3] sanitized = msg try: - print now + ": " + msg + print prefix + ": " + msg except Exception, s: try: sanitized = msg.encode("ascii", "backslashreplace") @@ -268,11 +268,11 @@ def dprint(msg): sanitized = "hex [" + msg.encode("hex") + "]" except Error, s: sanitized = "[unable to print debug message]" - print now + "~=" + sanitized + print prefix + "~=" + sanitized if options.log: sock = open(options.log, "a") - sock.write("%s skyped: %s\n" % (now, sanitized)) + sock.write(prefix + ": " + sanitized) sock.close() sys.stdout.flush() |