Skip to content

Commit

Permalink
Add sort to query debug logging.
Browse files Browse the repository at this point in the history
Closes spring-projects#4686
Original pull request: spring-projects#4679
  • Loading branch information
KSH-code authored and app committed May 20, 2024
1 parent 50a0eed commit 67c81ce
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2595,10 +2595,11 @@ protected <S, T> List<T> doFind(String collectionName,
QueryContext queryContext = queryOperations.createQueryContext(new BasicQuery(query, fields));
Document mappedFields = queryContext.getMappedFields(entity, EntityProjection.nonProjecting(entityClass));
Document mappedQuery = queryContext.getMappedQuery(entity);
Document mappedSort = getMappedSortObject(query, entityClass);

if (LOGGER.isDebugEnabled()) {
LOGGER.debug(String.format("find using query: %s fields: %s for class: %s in collection: %s",
serializeToJsonSafely(mappedQuery), mappedFields, entityClass, collectionName));
LOGGER.debug(String.format("find using query: %s fields: %s sort: %s for class: %s in collection: %s",
serializeToJsonSafely(mappedQuery), mappedSort, mappedFields, entityClass, collectionName));
}

return executeFindMultiInternal(new FindCallback(collectionPreparer, mappedQuery, mappedFields, null),
Expand All @@ -2620,10 +2621,11 @@ <S, T> List<T> doFind(CollectionPreparer<MongoCollection<Document>> collectionPr
QueryContext queryContext = queryOperations.createQueryContext(new BasicQuery(query, fields));
Document mappedFields = queryContext.getMappedFields(entity, projection);
Document mappedQuery = queryContext.getMappedQuery(entity);
Document mappedSort = getMappedSortObject(query, sourceClass);

if (LOGGER.isDebugEnabled()) {
LOGGER.debug(String.format("find using query: %s fields: %s for class: %s in collection: %s",
serializeToJsonSafely(mappedQuery), mappedFields, sourceClass, collectionName));
LOGGER.debug(String.format("find using query: %s fields: %s sort: %s for class: %s in collection: %s",
serializeToJsonSafely(mappedQuery), mappedSort, mappedFields, sourceClass, collectionName));
}

return executeFindMultiInternal(new FindCallback(collectionPreparer, mappedQuery, mappedFields, null), preparer,
Expand Down

0 comments on commit 67c81ce

Please sign in to comment.