watchd: beautify logging

This commit is contained in:
rofl0r
2019-01-07 05:45:09 +00:00
parent d93f14ad67
commit be99b8517b

View File

@@ -162,7 +162,7 @@ class WorkerThread():
class Proxywatchd():
def stop(self):
_log('Requesting proxywatchd to halt (%d thread(s))' % len([item for item in self.threads if True]))
_log('halting... (%d thread(s))' % len([item for item in self.threads if True]), 'watchd')
self.stopping.set()
def _cleanup(self):
@@ -223,7 +223,7 @@ class Proxywatchd():
def submit_collected(self):
if len(self.collected) == 0: return
_log("watchd main thread: updating %d entries"%len(self.collected))
_log("updating %d DB entries"%len(self.collected), 'watchd')
self._prep_db()
query = 'UPDATE proxylist SET failed=?,tested=?,dronebl=?,country=?,proto=?,success_count=?,total_duration=? WHERE proxy=?'
args = [ (job.failcount, job.nextcheck, 1, 'unknown', job.proto, job.success_count, job.total_duration, job.proxy) for job in self.collected ]
@@ -248,7 +248,7 @@ class Proxywatchd():
t.start()
def _run(self):
_log('Starting proxywatchd..', 'notice')
_log('starting...', 'watchd')
for i in range(config.watchd_threads):
threadid = ''.join( [ random.choice(string.letters) for x in range(5) ] )
@@ -277,7 +277,7 @@ class Proxywatchd():
# allow threads enough time to consume the jobs
sleeptime = 10
if len(self.jobs):
_log("watchd main: handing out %d jobs and %d thread(s)"% (len(self.jobs), config.watchd_threads))
_log("handing out %d jobs to %d thread(s)"% (len(self.jobs), config.watchd_threads), 'watchd')
jpt = len(self.jobs)/config.watchd_threads
if len(self.jobs)/float(config.watchd_threads) - jpt > 0.0: jpt += 1
for tid in range(config.watchd_threads):