logQuery: Log format modification

This commit is contained in:
Yuriy Lytvynchuk 2022-04-13 17:19:11 +03:00
parent cecbacfad4
commit 4b8e2efc38
2 changed files with 2 additions and 4 deletions

View File

@ -24,7 +24,6 @@ import org.springframework.jdbc.core.namedparam.ParsedSql;
import org.springframework.jdbc.core.namedparam.SqlParameterSource; import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -42,8 +41,8 @@ public class DefaultQueryLogComponent implements QueryLogComponent {
if (logSqlQueries && duration > logQueriesThreshold) { if (logSqlQueries && duration > logQueriesThreshold) {
String sqlToUse = substituteParametersInSqlString(query, ctx); String sqlToUse = substituteParametersInSqlString(query, ctx);
log.warn("SLOW QUERY took {} ms: {}", sqlToUse, duration); log.warn("SLOW QUERY took {} ms: {}", duration, sqlToUse);
Arrays.asList(ctx.getParameterNames()).forEach(param -> log.info("QUERY PARAM: {} -> {}", param, ctx.getValue(param)));
} }
} }

View File

@ -62,7 +62,6 @@ public class DefaultQueryLogComponentTest {
@Test @Test
public void logQuery() { public void logQuery() {
BDDMockito.willCallRealMethod().given(queryLog).logQuery(ctx, "", 3000);
BDDMockito.willReturn("").given(queryLog).substituteParametersInSqlString("", ctx); BDDMockito.willReturn("").given(queryLog).substituteParametersInSqlString("", ctx);
queryLog.logQuery(ctx, "", 3000); queryLog.logQuery(ctx, "", 3000);