def log_query_and_profile_data_for_queryset(queryset):
 if (not ENABLE_PROFILING):
  return queryset
 if (not isinstance(queryset, QuerySet)):
  return queryset
 query = getattr(queryset, '_query', None)
 mongo_query = getattr(queryset, '_mongo_query', query)
 ordering = getattr(queryset, '_ordering', None)
 limit = getattr(queryset, '_limit', None)
 collection = getattr(queryset, '_collection', None)
 collection_name = getattr(collection, 'name', None)
 cloned_queryset = queryset.clone()
 explain_info = cloned_queryset.explain(format=True)
 if ((mongo_query is not None) and (collection_name is not None)):
  mongo_shell_query = construct_mongo_shell_query(mongo_query=mongo_query, collection_name=collection_name, ordering=ordering, limit=limit)
  extra = {'mongo_query': mongo_query, 'mongo_shell_query': mongo_shell_query}
  LOG.debug(('MongoDB query: %s' % mongo_shell_query), extra=extra)
  LOG.debug(('MongoDB explain data: %s' % explain_info))
 return queryset

def log_query_and_profile_data_for_queryset ( queryset ) : if ( not ENABLE_PROFILING ) : return queryset if ( not isinstance ( queryset , QuerySet ) ) : return queryset query = getattr ( queryset , '_query' , None ) mongo_query = getattr ( queryset , '_mongo_query' , query ) ordering = getattr ( queryset , '_ordering' , None ) limit = getattr ( queryset , '_limit' , None ) collection = getattr ( queryset , '_collection' , None ) collection_name = getattr ( collection , 'name' , None ) cloned_queryset = queryset . clone ( ) explain_info = cloned_queryset . explain ( format = True ) if ( ( mongo_query is not None ) and ( collection_name is not None ) ) : mongo_shell_query = construct_mongo_shell_query ( mongo_query = mongo_query , collection_name = collection_name , ordering = ordering , limit = limit ) extra = { 'mongo_query' : mongo_query , 'mongo_shell_query' : mongo_shell_query } LOG . debug ( ( 'MongoDB query: %s' % mongo_shell_query ) , extra = extra ) LOG . debug ( ( 'MongoDB explain data: %s' % explain_info ) ) return queryset
function which logs mongodb query and profile data for the provided mongoengine queryset object .