Convert logs to message supplier pattern

This commit is contained in:
Madhavan Sridharan 2024-08-14 23:05:37 -04:00
parent c3e55ab5fc
commit 9c8cf1f2ec
5 changed files with 12 additions and 16 deletions

View File

@ -90,8 +90,8 @@ public class AzureAISearchSpace implements AutoCloseable {
}).orElseGet(() -> cfg.getOptional("token").orElseThrow(() -> new RuntimeException(
"You must provide either a 'token_file' or a 'token' to configure a Azure AI Search client")));
logger.info("{}: Creating new Azure AI Search Client with (masked) token/key [{}], uri/endpoint [{}]",
this.name, AzureAISearchAdapterUtils.maskDigits(requiredToken), uri);
logger.info(() -> "Creating new Azure AI Search Client with (masked) token/key ["
+ AzureAISearchAdapterUtils.maskDigits(requiredToken) + "], uri/endpoint [" + uri + "]");
var searchIndexClientBuilder = new SearchIndexClientBuilder().endpoint(uri);
if (!requiredToken.isBlank()) {
@ -103,8 +103,8 @@ public class AzureAISearchSpace implements AutoCloseable {
// Should we leave these below to leverage the SearchServiceVersion.getLatest()?
String apiVersion = cfg.getOptional("api_version").orElse(SearchServiceVersion.V2024_07_01.name());
logger.warn(
"Latest search service version supported by this client is '{}', but we're using '{}' version. Ignore this warning if both are same.",
SearchServiceVersion.getLatest(), apiVersion);
() -> "Latest search service version supported by this client is '" + SearchServiceVersion.getLatest()
+ "', but we're using '" + apiVersion + "' version. Ignore this warning if both are same.");
return searchIndexClientBuilder.serviceVersion(SearchServiceVersion.valueOf(apiVersion)).buildClient();
}

View File

@ -48,7 +48,7 @@ public abstract class AzureAISearchBaseOp<T> implements CycleOp<Object> {
@Override
public final Object apply(long value) {
logger.trace("applying op: " + this);
logger.trace(() -> "applying op: " + this);
try {
Object result = applyOp(value);

View File

@ -30,12 +30,11 @@ public class AzureAISearchListIndexesOp extends AzureAISearchBaseOp<String> {
try {
PagedIterable<SearchIndex> response = searchIndexClient.listIndexes();
response.forEach((index) -> {
logger.info("Indexes available are: Name: {}, ETag: {}", index.getName(), index.getETag());
logger.info(() -> "Indexes available are: Name: " + index.getName() + ", ETag: " + index.getETag());
index.getFields().forEach(field -> {
logger.info(
"Field Name: {}, Field isKey?: {}, Field Dimension: {}, Field Vector Search Profile: {}",
field.getName(), field.isKey(), field.getVectorSearchDimensions(),
field.getVectorSearchProfileName());
logger.info(() -> "Field Name: " + field.getName() + ", Field isKey?: " + field.isKey()
+ ", Field Dimension: " + field.getVectorSearchDimensions()
+ ", Field Vector Search Profile: " + field.getVectorSearchProfileName());
});
});
} catch (RuntimeException rte) {

View File

@ -36,9 +36,9 @@ public class AzureAISearchUploadDocumentsOp extends AzureAISearchClientBaseOp<Se
uploadDocsResponse = searchClient.uploadDocuments(List.of(request));
if (logger.isDebugEnabled()) {
uploadDocsResponse.getResults().forEach((r) -> {
logger.debug(
"Successfully created the collection with return status code: {}, key: {}, succeeded?: {}, error message: {}",
r.getStatusCode(), r.getKey(), r.isSucceeded(), r.getErrorMessage());
logger.debug(() -> "Successfully created the collection with return status code: "
+ r.getStatusCode() + ", key: " + r.getKey() + ", succeeded?: " + r.isSucceeded()
+ ", error message: " + r.getErrorMessage());
});
}
} catch (RuntimeException rte) {

View File

@ -129,9 +129,6 @@ public class AzureAISearchCreateOrUpdateIndexOpDispenser extends AzureAISearchBa
BinaryQuantizationCompression bqComp = new BinaryQuantizationCompression(innerKey);
((Map<String, Object>) innerValue).forEach((compressKey, compressValue) -> {
logger.debug(
">>>>>>>>>>>>AzureAISearchCreateOrUpdateIndexOpDispenser>>>>>>>>>>>>VectorSearch>>>>buildVectorSearchStruct>>>>kind:{} compressKey:{} compressValue:{}",
kind, compressKey, compressValue);
if (compressKey.equals("kind")) {
bqComp.getKind().fromString((String) compressValue);
}