improvements in logging

This commit is contained in:
Manuel Amador (Rudd-O) 2015-10-20 18:37:43 +00:00
parent a09dd080c6
commit ad02b71c57

View File

@ -16,6 +16,8 @@ import threading
debug_lock = threading.Lock() debug_lock = threading.Lock()
debug_enabled = False debug_enabled = False
class LoggingEmu(): class LoggingEmu():
def __init__(self, prefix):
self.prefix = prefix
def debug(self, *a, **kw): def debug(self, *a, **kw):
if not debug_enabled: if not debug_enabled:
return return
@ -31,10 +33,10 @@ class LoggingEmu():
string = a[0] string = a[0]
else: else:
string = a[0] % a[1:] string = a[0] % a[1:]
print >> sys.stderr, string print >> sys.stderr, self.prefix, string
finally: finally:
debug_lock.release() debug_lock.release()
logging = LoggingEmu() logging = LoggingEmu("master:" if "__file__" in globals() else "remote:")
def send_command(chan, cmd): def send_command(chan, cmd):
@ -72,6 +74,7 @@ def send_confirmation(chan, retval, errmsg):
def recv_confirmation(chan): def recv_confirmation(chan):
logging.debug("Waiting for confirmation")
r = chan.read(2) r = chan.read(2)
if len(r) == 0: if len(r) == 0:
# This happens when the remote domain does not exist. # This happens when the remote domain does not exist.