improve debug output

This commit is contained in:
2018-01-17 00:01:49 +01:00
parent c1334fead9
commit 6902e2a80c
2 changed files with 15 additions and 4 deletions
+7 -3
View File
@@ -316,8 +316,9 @@ def checkoverdue():
def log(host, m, service=None):
if DEBUG > 0: print "Log: %s" % m
ts = time.strftime("%b %d %H:%M:%S", time.localtime(time.time()))
if DEBUG > 0: print "Log: %s %s" % (host, m)
now = time.time()
ts = time.strftime("%b %d %H:%M:%S", time.localtime(now))
if service:
srv = "service %s: " % service
else:
@@ -374,6 +375,7 @@ def readsock(sock):
name = shortname(msg.get('name', "unknown"))
if not name in Host.hosts: # was: hosts.has_key(name):
host = Host(name)
host.dyn = h in dyndnshosts
if verbose: print "XX: New host, num now %s" % (len(Host.hosts))
newh=True
else:
@@ -612,6 +614,7 @@ class HttpHandler(BaseHTTPServer.BaseHTTPRequestHandler):
code, res=self.builderror(400, 'Data error', "h=%s not found" % uname)
else:
log(uname, "dropped")
# for addr in Host.hosts[uname].0i
del Host.hosts[uname]
res=self.buildhead()
res.append("Done")
@@ -884,7 +887,8 @@ if 1 and os.path.exists(pickfile):
except:
lastfm = ["","",""]
pickf.close()
except:
except Exception as e:
print "load pickled failed: %s" % e
os.unlink(pickfile)
Connection.htab = {}
for h in Host.hosts.keys():
+8 -1
View File
@@ -13,7 +13,13 @@ num = 0
MAXRTTS = 10
#
DEBUG=1
def log(host, m):
if DEBUG:
print "class log: %s %s" % (host, m)
class Connection:
# map of addrs to names
@@ -38,6 +44,7 @@ class Connection:
r = "new addr %s" % (addr)
Connection.htab[addr] = self.host.name
if self.host.isDynDns():
log(self.host.name, "dns update %s" % self.addr)
Host.dnsQ.put((self.host.name, self.addr))
def registerDns(self):