def _patch_logger_class():
 try:
  from multiprocessing.process import current_process
 except ImportError:
  current_process = None
 logging._acquireLock()
 try:
  OldLoggerClass = logging.getLoggerClass()
  if (not getattr(OldLoggerClass, '_process_aware', False)):
   class ProcessAwareLogger(OldLoggerClass, ):
    _process_aware = True
    def makeRecord(self, *args, **kwds):
     record = OldLoggerClass.makeRecord(self, *args, **kwds)
     if current_process:
      record.processName = current_process()._name
     else:
      record.processName = ''
     return record
   logging.setLoggerClass(ProcessAwareLogger)
 finally:
  logging._releaseLock()

def _patch_logger_class ( ) : try : from multiprocessing . process import current_process except ImportError : current_process = None logging . _acquireLock ( ) try : OldLoggerClass = logging . getLoggerClass ( ) if ( not getattr ( OldLoggerClass , '_process_aware' , False ) ) : class ProcessAwareLogger ( OldLoggerClass , ) : _process_aware = True def makeRecord ( self , * args , ** kwds ) : record = OldLoggerClass . makeRecord ( self , * args , ** kwds ) if current_process : record . processName = current_process ( ) . _name else : record . processName = '' return record logging . setLoggerClass ( ProcessAwareLogger ) finally : logging . _releaseLock ( )
make sure process name is recorded when loggers are used .