def _find_console_stream_handler(logger):
 for handler in logger.handlers:
  if (isinstance(handler, logging.StreamHandler) and (handler.stream in (sys.stderr, sys.stdout))):
   return logger
 return None

def _find_console_stream_handler ( logger ) : for handler in logger . handlers : if ( isinstance ( handler , logging . StreamHandler ) and ( handler . stream in ( sys . stderr , sys . stdout ) ) ) : return logger return None
find a streamhandler that is attached to the logger that prints to the console .