From 52ceb4b1e90f1b8640e7a232a3fe02b2748ae1b2 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 6 Mar 2013 20:56:19 +0100 Subject: skyped: prefix debug messages with source location --- protocols/skype/skyped.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'protocols/skype/skyped.py') 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() -- cgit v1.2.3