Skip to content

Commit 808d282

Browse files
KSH-codemp911de
authored andcommitted
Add sort to query debug logging.
Closes #4686 Original pull request: #4679
1 parent be3372b commit 808d282

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Diff for: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -2595,10 +2595,11 @@ protected <S, T> List<T> doFind(String collectionName,
25952595
QueryContext queryContext = queryOperations.createQueryContext(new BasicQuery(query, fields));
25962596
Document mappedFields = queryContext.getMappedFields(entity, EntityProjection.nonProjecting(entityClass));
25972597
Document mappedQuery = queryContext.getMappedQuery(entity);
2598+
Document mappedSort = getMappedSortObject(query, entityClass);
25982599

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

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

26242626
if (LOGGER.isDebugEnabled()) {
2625-
LOGGER.debug(String.format("find using query: %s fields: %s for class: %s in collection: %s",
2626-
serializeToJsonSafely(mappedQuery), mappedFields, sourceClass, collectionName));
2627+
LOGGER.debug(String.format("find using query: %s fields: %s sort: %s for class: %s in collection: %s",
2628+
serializeToJsonSafely(mappedQuery), mappedSort, mappedFields, sourceClass, collectionName));
26272629
}
26282630

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

0 commit comments

Comments
 (0)