def setup_multiprocessing_logging(queue=None):
 from salt.utils import is_windows
 global __MP_LOGGING_CONFIGURED
 global __MP_LOGGING_QUEUE_HANDLER
 if ((__MP_IN_MAINPROCESS is True) and (not is_windows())):
  return
 try:
  logging._acquireLock()
  if (__MP_LOGGING_CONFIGURED is True):
   return
  __MP_LOGGING_CONFIGURED = True
  if (__MP_LOGGING_QUEUE_HANDLER is not None):
   return
  __remove_null_logging_handler()
  __remove_queue_logging_handler()
  __MP_LOGGING_QUEUE_HANDLER = SaltLogQueueHandler((queue or get_multiprocessing_logging_queue()))
  logging.root.addHandler(__MP_LOGGING_QUEUE_HANDLER)
  logging.root.setLevel(logging.GARBAGE)
  logging.getLogger(__name__).debug('Multiprocessing queue logging configured for the process running under PID: {0}'.format(os.getpid()))
  time.sleep(0.0001)
 finally:
  logging._releaseLock()

def setup_multiprocessing_logging ( queue = None ) : from salt . utils import is_windows global __MP_LOGGING_CONFIGURED global __MP_LOGGING_QUEUE_HANDLER if ( ( __MP_IN_MAINPROCESS is True ) and ( not is_windows ( ) ) ) : return try : logging . _acquireLock ( ) if ( __MP_LOGGING_CONFIGURED is True ) : return __MP_LOGGING_CONFIGURED = True if ( __MP_LOGGING_QUEUE_HANDLER is not None ) : return __remove_null_logging_handler ( ) __remove_queue_logging_handler ( ) __MP_LOGGING_QUEUE_HANDLER = SaltLogQueueHandler ( ( queue or get_multiprocessing_logging_queue ( ) ) ) logging . root . addHandler ( __MP_LOGGING_QUEUE_HANDLER ) logging . root . setLevel ( logging . GARBAGE ) logging . getLogger ( __name__ ) . debug ( 'Multiprocessing queue logging configured for the process running under PID: {0}' . format ( os . getpid ( ) ) ) time . sleep ( 0.0001 ) finally : logging . _releaseLock ( )
this code should be called from within a running multiprocessing process instance .