Explorar o código

Tweak logging parameters to include additional information and drop exc_info as its causing a failure

David Cramer %!s(int64=14) %!d(string=hai) anos
pai
achega
e317dea548
Modificáronse 2 ficheiros con 16 adicións e 2 borrados
  1. 7 1
      celery/worker/controllers.py
  2. 9 1
      celery/worker/job.py

+ 7 - 1
celery/worker/controllers.py

@@ -55,7 +55,13 @@ class Mediator(threading.Thread):
             self.callback(task)
         except Exception, exc:
             self.logger.error("Mediator callback raised exception %r\n%s" % (
-                exc, traceback.format_exc()), exc_info=sys.exc_info())
+                exc, traceback.format_exc()), exc_info=sys.exc_info(), extra={
+                    "data": {
+                        "hostname": task.hostname,
+                        "id": task.task_id,
+                        "name": task.task_name,
+                    }
+                })
 
     def run(self):
         while not self._shutdown.isSet():

+ 9 - 1
celery/worker/job.py

@@ -469,7 +469,15 @@ class TaskRequest(object):
                    "traceback": unicode(exc_info.traceback, 'utf-8'),
                    "args": self.args,
                    "kwargs": self.kwargs}
-        self.logger.error(self.error_msg.strip() % context, exc_info=exc_info)
+
+        self.logger.error(self.error_msg.strip() % context,
+                          extra={
+                              "data": {
+                                  "hostname": self.hostname,
+                                  "id": self.task_id,
+                                  "name": self.task_name,
+                              }
+                          })
 
         task_obj = tasks.get(self.task_name, object)
         self.send_error_email(task_obj, context, exc_info.exception,