Skip to content

Commit 942cd10

Browse files
committed
Avoid string concatenation in logging calls
Signed-off-by: Łukasz Jernaś <[email protected]>
1 parent f7d8f0f commit 942cd10

File tree

13 files changed

+22
-24
lines changed

13 files changed

+22
-24
lines changed

models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/api/AbstractBedrockApi.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ protected Flux<SO> internalInvocationStream(I request, Class<SO> clazz) {
287287
.builder()
288288
.onChunk(chunk -> {
289289
try {
290-
logger.debug("Received chunk: " + chunk.bytes().asString(StandardCharsets.UTF_8));
290+
logger.debug("Received chunk: {}",chunk.bytes().asString(StandardCharsets.UTF_8));
291291
SO response = this.objectMapper.readValue(chunk.bytes().asByteArray(), clazz);
292292
eventSink.emitNext(response, DEFAULT_EMIT_FAILURE_HANDLER);
293293
}
@@ -297,7 +297,7 @@ protected Flux<SO> internalInvocationStream(I request, Class<SO> clazz) {
297297
}
298298
})
299299
.onDefault(event -> {
300-
logger.error("Unknown or unhandled event: " + event.toString());
300+
logger.error("Unknown or unhandled event: {}",event.toString());
301301
eventSink.emitError(new Throwable("Unknown or unhandled event: " + event.toString()), DEFAULT_EMIT_FAILURE_HANDLER);
302302
})
303303
.build();
@@ -310,7 +310,7 @@ protected Flux<SO> internalInvocationStream(I request, Class<SO> clazz) {
310310
logger.info("Completed streaming response.");
311311
})
312312
.onError(error -> {
313-
logger.error("\n\nError streaming response: " + error.getMessage());
313+
logger.error("\n\nError streaming response: {}",error.getMessage());
314314
eventSink.emitError(error, DEFAULT_EMIT_FAILURE_HANDLER);
315315
})
316316
.onEventStream(stream -> stream.subscribe(

spring-ai-commons/src/main/java/org/springframework/ai/transformer/splitter/TextSplitter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private List<Document> createDocuments(List<String> texts, List<ContentFormatter
8484
Map<String, Object> metadata = metadataList.get(i);
8585
List<String> chunks = splitText(text);
8686
if (chunks.size() > 1) {
87-
logger.info("Splitting up document into " + chunks.size() + " chunks.");
87+
logger.info("Splitting up document into {} chunks.", chunks.size());
8888
}
8989
for (String chunk : chunks) {
9090
// only primitive values are in here -

spring-ai-retry/src/main/java/org/springframework/ai/retry/RetryUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void handleError(@NonNull ClientHttpResponse response) throws IOException
8888
@Override
8989
public <T extends Object, E extends Throwable> void onError(RetryContext context,
9090
RetryCallback<T, E> callback, Throwable throwable) {
91-
logger.warn("Retry error. Retry count:" + context.getRetryCount(), throwable);
91+
logger.warn("Retry error. Retry count:{}", context.getRetryCount(), throwable);
9292
}
9393
})
9494
.build();
@@ -107,7 +107,7 @@ public <T extends Object, E extends Throwable> void onError(RetryContext context
107107
@Override
108108
public <T extends Object, E extends Throwable> void onError(RetryContext context,
109109
RetryCallback<T, E> callback, Throwable throwable) {
110-
logger.warn("Retry error. Retry count:" + context.getRetryCount());
110+
logger.warn("Retry error. Retry count:{}", context.getRetryCount());
111111
}
112112
})
113113
.build();

vector-stores/spring-ai-azure-store/src/main/java/org/springframework/ai/vectorstore/azure/AzureVectorStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ public void afterPropertiesSet() throws Exception {
303303

304304
SearchIndex index = this.searchIndexClient.createOrUpdateIndex(searchIndex);
305305

306-
logger.info("Created search index: " + index.getName());
306+
logger.info("Created search index: {}", index.getName());
307307

308308
this.searchClient = this.searchIndexClient.getSearchClient(this.indexName);
309309
}

vector-stores/spring-ai-chroma-store/src/main/java/org/springframework/ai/chroma/vectorstore/ChromaVectorStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ protected void doDelete(Filter.Expression expression) {
189189

190190
Map<String, Object> whereClause = this.chromaApi.where(whereClauseStr);
191191

192-
logger.debug("Deleting with where clause: " + whereClause);
192+
logger.debug("Deleting with where clause: {}", whereClause);
193193

194194
DeleteEmbeddingsRequest deleteRequest = new DeleteEmbeddingsRequest(null, whereClause);
195195
this.chromaApi.deleteEmbeddings(this.tenantName, this.databaseName, this.collectionId, deleteRequest);

vector-stores/spring-ai-mariadb-store/src/main/java/org/springframework/ai/vectorstore/mariadb/MariaDBSchemaValidator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void validateTableSchema(String schemaName, String tableName, String idFieldName
7272
schemaName, tableName);
7373
}
7474
catch (DataAccessException e) {
75-
logger.error("Error while validating database vector support " + e.getMessage());
75+
logger.error("Error while validating database vector support {}", e.getMessage());
7676
logger.error("Failed to validate that database supports VECTOR.\n" + "Run the following SQL commands:\n"
7777
+ " SELECT @@version; \nAnd ensure that version is >= 11.7.1");
7878
throw new IllegalStateException(e);
@@ -118,7 +118,7 @@ void validateTableSchema(String schemaName, String tableName, String idFieldName
118118

119119
}
120120
catch (DataAccessException | IllegalStateException e) {
121-
logger.error("Error while validating table schema" + e.getMessage());
121+
logger.error("Error while validating table schema{}", e.getMessage());
122122
logger.error("Failed to operate with the specified table in the database. To resolve this issue,"
123123
+ " please ensure the following steps are completed:\n"
124124
+ "1. Verify that the table exists with the appropriate structure. If it does not"

vector-stores/spring-ai-mariadb-store/src/main/java/org/springframework/ai/vectorstore/mariadb/MariaDBVectorStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ public List<Document> doSimilaritySearch(SearchRequest request) {
364364
this.idFieldName, this.contentFieldName, this.metadataFieldName, distanceType, this.embeddingFieldName,
365365
getFullyQualifiedTableName(), jsonPathFilter);
366366

367-
logger.debug("SQL query: " + sql);
367+
logger.debug("SQL query: {}", sql);
368368

369369
return this.jdbcTemplate.query(sql, new DocumentRowMapper(this.objectMapper), embedding, distance,
370370
request.getTopK());

vector-stores/spring-ai-milvus-store/src/main/java/org/springframework/ai/vectorstore/milvus/MilvusVectorStore.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public void doDelete(List<String> idList) {
292292

293293
long deleteCount = status.getData().getDeleteCnt();
294294
if (deleteCount != idList.size()) {
295-
logger.warn(String.format("Deleted only %s entries from requested %s ", deleteCount, idList.size()));
295+
logger.warn("Deleted only {} entries from requested {} ", deleteCount, idList.size());
296296
}
297297
}
298298

@@ -544,8 +544,7 @@ int embeddingDimensions() {
544544
}
545545
}
546546
catch (Exception e) {
547-
logger.warn("Failed to obtain the embedding dimensions from the embedding model and fall backs to default:"
548-
+ this.embeddingDimension, e);
547+
logger.warn("Failed to obtain the embedding dimensions from the embedding model and fall backs to default:{}", this.embeddingDimension, e);
549548
}
550549
return OPENAI_EMBEDDING_DIMENSION_SIZE;
551550
}

vector-stores/spring-ai-mongodb-atlas-store/src/main/java/org/springframework/ai/vectorstore/mongodb/atlas/MongoDBAtlasVectorStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ protected void doDelete(Filter.Expression filterExpression) {
282282
BasicQuery query = new BasicQuery(nativeFilterExpression);
283283
DeleteResult deleteResult = this.mongoTemplate.remove(query, this.collectionName);
284284

285-
logger.debug("Deleted " + deleteResult.getDeletedCount() + " documents matching filter expression");
285+
logger.debug("Deleted {} documents matching filter expression", deleteResult.getDeletedCount());
286286
}
287287
catch (Exception e) {
288288
throw new IllegalStateException("Failed to delete documents by filter", e);

vector-stores/spring-ai-opensearch-store/src/main/java/org/springframework/ai/vectorstore/opensearch/OpenSearchVectorStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ protected void doDelete(Filter.Expression filterExpression) {
249249
.build();
250250

251251
DeleteByQueryResponse response = this.openSearchClient.deleteByQuery(request);
252-
logger.debug("Deleted " + response.deleted() + " documents matching filter expression");
252+
logger.debug("Deleted {} documents matching filter expression", response.deleted());
253253

254254
if (!response.failures().isEmpty()) {
255255
throw new IllegalStateException("Failed to delete some documents: " + response.failures());

0 commit comments

Comments
 (0)