فهرست منبع

Have to make sure processName is supported by foreign logger instances.

processName is always supported by Python 2.7
Ask Solem 14 سال پیش
والد
کامیت
306e72e782
1فایلهای تغییر یافته به همراه7 افزوده شده و 0 حذف شده
  1. 7 0
      celery/log.py

+ 7 - 0
celery/log.py

@@ -6,6 +6,8 @@ import os
 import sys
 import traceback
 
+from multiprocessing import current_process
+
 from celery import conf
 from celery import signals
 from celery.utils import noop
@@ -38,6 +40,11 @@ class ColorFormatter(logging.Formatter):
         if self.use_color and levelname in COLORS:
             record.msg = COLOR_SEQ % (
                     30 + COLORS[levelname]) + record.msg + RESET_SEQ
+        # Very ugly, but have to make sure processName is supported
+        # by foreign logger instances.
+        # (processName is always supported by Python 2.7)
+        if "processName" not in record.__dict__:
+            record.__dict__["processName"] = current_process()._name
         return logging.Formatter.format(self, record)