From 1358246238a12388b33e3427bd4175e19032bcb6 Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Mon, 21 Nov 2011 17:10:58 +0100 Subject: [PATCH] Better logging output. --- rq/queue.py | 8 ++++---- rq/worker.py | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/rq/queue.py b/rq/queue.py index cea592c..6dc6633 100644 --- a/rq/queue.py +++ b/rq/queue.py @@ -57,11 +57,11 @@ class Job(object): return self.func(*self.args, **self.kwargs) def __str__(self): - return '' % ( + arg_list = map(repr, self.args) + arg_list += map(lambda key, val: '%s=%r' % (key, val), self.kwargs.items()) + return '' % ( self.func.__name__, - ', '.join( - map(repr, self.args) + - map(lambda key, val: '%s=%r' % (key, val), self.kwargs.items()))) + ', '.join(arg_list)) @total_ordering diff --git a/rq/worker.py b/rq/worker.py index 4348519..79e4272 100644 --- a/rq/worker.py +++ b/rq/worker.py @@ -117,7 +117,6 @@ class Worker(object): This can be used to make `ps -ef` output more readable. """ - self.log.debug(message) procname.setprocname('rq: %s' % (message,)) @@ -164,7 +163,9 @@ class Worker(object): try: while True: self.state = 'idle' - self.procline('Waiting on %s' % (', '.join(self.queue_names()),)) + qnames = ', '.join(self.queue_names()) + self.procline('Waiting on %s' % (qnames,)) + self.log.info('Watching queues: %s' % (qnames,)) wait_for_job = not quit_when_done job = Queue.dequeue_any(self.queues, wait_for_job) if job is None: @@ -199,7 +200,6 @@ class Worker(object): random.seed() self.log = Logger('horse') try: - self.procline('Processing work since %d' % (time.time(),)) self.perform_job(job) except Exception, e: self.log.exception(e) @@ -211,6 +211,8 @@ class Worker(object): def perform_job(self, job): self.procline('Processing %s from %s since %s' % (job.func.__name__, job.origin.name, time.time())) + msg = 'Processing job %s from queue %s' % (job, job.origin.name) + self.log.debug(msg) try: rv = job.perform() except Exception, e: