Skip to content

Commit 2932769

Browse files
ilayaperumalgmarkpollack
authored andcommitted
Switch back to use slf4j logging
- Revert the changes to update to use Apache Commons Logging and re-add the previously used slf4j logging
1 parent b86772d commit 2932769

File tree

199 files changed

+1063
-814
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

199 files changed

+1063
-814
lines changed

document-readers/pdf-reader/src/main/java/org/springframework/ai/reader/pdf/PagePdfDocumentReader.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@
2222
import java.util.List;
2323
import java.util.stream.Collectors;
2424

25-
import org.apache.commons.logging.LogFactory;
2625
import org.apache.pdfbox.pdfparser.PDFParser;
2726
import org.apache.pdfbox.pdmodel.PDDocument;
2827
import org.apache.pdfbox.pdmodel.PDPage;
28+
import org.slf4j.Logger;
29+
import org.slf4j.LoggerFactory;
2930

3031
import org.springframework.ai.document.Document;
3132
import org.springframework.ai.document.DocumentReader;
3233
import org.springframework.ai.reader.pdf.config.PdfDocumentReaderConfig;
3334
import org.springframework.ai.reader.pdf.layout.PDFLayoutTextStripperByArea;
3435
import org.springframework.core.io.DefaultResourceLoader;
3536
import org.springframework.core.io.Resource;
36-
import org.springframework.core.log.LogAccessor;
3737
import org.springframework.util.CollectionUtils;
3838
import org.springframework.util.StringUtils;
3939

@@ -55,10 +55,10 @@ public class PagePdfDocumentReader implements DocumentReader {
5555

5656
private static final String PDF_PAGE_REGION = "pdfPageRegion";
5757

58-
private static final LogAccessor logger = new LogAccessor(LogFactory.getLog(PagePdfDocumentReader.class));
59-
6058
protected final PDDocument document;
6159

60+
private final Logger logger = LoggerFactory.getLogger(getClass());
61+
6262
protected String resourceFileName;
6363

6464
private PdfDocumentReaderConfig config;
@@ -112,7 +112,7 @@ public List<Document> get() {
112112
for (PDPage page : this.document.getDocumentCatalog().getPages()) {
113113
lastPage = page;
114114
if (counter % logFrequency == 0 && counter / logFrequency < 10) {
115-
logger.info("Processing PDF page: " + (counter + 1));
115+
logger.info("Processing PDF page: {}", (counter + 1));
116116
}
117117
counter++;
118118

@@ -154,7 +154,7 @@ public List<Document> get() {
154154
readDocuments.add(toDocument(lastPage, pageTextGroupList.stream().collect(Collectors.joining()),
155155
startPageNumber, pageNumber));
156156
}
157-
logger.info("Processing " + totalPages + " pages");
157+
logger.info("Processing {} pages", totalPages);
158158
return readDocuments;
159159

160160
}

document-readers/pdf-reader/src/main/java/org/springframework/ai/reader/pdf/ParagraphPdfDocumentReader.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
import org.apache.pdfbox.pdfparser.PDFParser;
2525
import org.apache.pdfbox.pdmodel.PDDocument;
26+
import org.slf4j.Logger;
27+
import org.slf4j.LoggerFactory;
2628

2729
import org.springframework.ai.document.Document;
2830
import org.springframework.ai.document.DocumentReader;
@@ -32,7 +34,6 @@
3234
import org.springframework.ai.reader.pdf.layout.PDFLayoutTextStripperByArea;
3335
import org.springframework.core.io.DefaultResourceLoader;
3436
import org.springframework.core.io.Resource;
35-
import org.springframework.core.log.LogAccessor;
3637
import org.springframework.util.CollectionUtils;
3738
import org.springframework.util.StringUtils;
3839

@@ -61,7 +62,7 @@ public class ParagraphPdfDocumentReader implements DocumentReader {
6162

6263
protected final PDDocument document;
6364

64-
private static final LogAccessor logger = new LogAccessor(ParagraphPdfDocumentReader.class);
65+
private final Logger logger = LoggerFactory.getLogger(getClass());
6566

6667
private final ParagraphManager paragraphTextExtractor;
6768

models/spring-ai-anthropic/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@
7777
<artifactId>spring-context-support</artifactId>
7878
</dependency>
7979

80+
<dependency>
81+
<groupId>org.slf4j</groupId>
82+
<artifactId>slf4j-api</artifactId>
83+
</dependency>
84+
8085
<!-- test dependencies -->
8186
<dependency>
8287
<groupId>org.springframework.ai</groupId>

models/spring-ai-anthropic/src/main/java/org/springframework/ai/anthropic/AnthropicChatModel.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import io.micrometer.observation.Observation;
2828
import io.micrometer.observation.ObservationRegistry;
2929
import io.micrometer.observation.contextpropagation.ObservationThreadLocalAccessor;
30+
import org.slf4j.Logger;
31+
import org.slf4j.LoggerFactory;
3032
import reactor.core.publisher.Flux;
3133
import reactor.core.publisher.Mono;
3234

@@ -65,7 +67,6 @@
6567
import org.springframework.ai.model.function.FunctionCallbackResolver;
6668
import org.springframework.ai.model.function.FunctionCallingOptions;
6769
import org.springframework.ai.retry.RetryUtils;
68-
import org.springframework.core.log.LogAccessor;
6970
import org.springframework.http.ResponseEntity;
7071
import org.springframework.retry.support.RetryTemplate;
7172
import org.springframework.util.Assert;
@@ -91,7 +92,7 @@ public class AnthropicChatModel extends AbstractToolCallSupport implements ChatM
9192

9293
public static final Double DEFAULT_TEMPERATURE = 0.8;
9394

94-
private static final LogAccessor logger = new LogAccessor(AnthropicChatModel.class);
95+
private static final Logger logger = LoggerFactory.getLogger(AnthropicChatModel.class);
9596

9697
private static final ChatModelObservationConvention DEFAULT_OBSERVATION_CONVENTION = new DefaultChatModelObservationConvention();
9798

models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/AnthropicChatModelIT.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
2828
import org.junit.jupiter.params.ParameterizedTest;
2929
import org.junit.jupiter.params.provider.ValueSource;
30+
import org.slf4j.Logger;
31+
import org.slf4j.LoggerFactory;
3032
import reactor.core.publisher.Flux;
3133

3234
import org.springframework.ai.anthropic.api.AnthropicApi;
@@ -57,7 +59,6 @@
5759
import org.springframework.core.convert.support.DefaultConversionService;
5860
import org.springframework.core.io.ClassPathResource;
5961
import org.springframework.core.io.Resource;
60-
import org.springframework.core.log.LogAccessor;
6162
import org.springframework.util.MimeType;
6263
import org.springframework.util.MimeTypeUtils;
6364
import org.springframework.util.StringUtils;
@@ -68,7 +69,7 @@
6869
@EnabledIfEnvironmentVariable(named = "ANTHROPIC_API_KEY", matches = ".+")
6970
class AnthropicChatModelIT {
7071

71-
private static final LogAccessor logger = new LogAccessor(AnthropicChatModelIT.class);
72+
private static final Logger logger = LoggerFactory.getLogger(AnthropicChatModelIT.class);
7273

7374
@Autowired
7475
protected ChatModel chatModel;
@@ -282,7 +283,7 @@ void functionCallTest() {
282283

283284
ChatResponse response = this.chatModel.call(new Prompt(messages, promptOptions));
284285

285-
logger.info("Response: " + response);
286+
logger.info("Response: {}", response);
286287

287288
Generation generation = response.getResult();
288289
assertThat(generation).isNotNull();
@@ -321,7 +322,7 @@ void streamFunctionCallTest() {
321322
.map(cr -> cr.getResult().getOutput().getText())
322323
.collect(Collectors.joining());
323324

324-
logger.info("Response: " + content);
325+
logger.info("Response: {}", content);
325326
assertThat(content).contains("30", "10", "15");
326327
}
327328

@@ -346,7 +347,7 @@ void streamFunctionCallUsageTest() {
346347

347348
ChatResponse chatResponse = responseFlux.last().block();
348349

349-
logger.info("Response: " + chatResponse);
350+
logger.info("Response: {}", chatResponse);
350351
Usage usage = chatResponse.getMetadata().getUsage();
351352

352353
assertThat(usage).isNotNull();

models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/EventParsingTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@
2323
import com.fasterxml.jackson.core.type.TypeReference;
2424
import com.fasterxml.jackson.databind.ObjectMapper;
2525
import org.junit.jupiter.api.Test;
26+
import org.slf4j.Logger;
27+
import org.slf4j.LoggerFactory;
2628

2729
import org.springframework.ai.anthropic.api.AnthropicApi.StreamEvent;
2830
import org.springframework.core.io.DefaultResourceLoader;
29-
import org.springframework.core.log.LogAccessor;
3031

3132
import static org.assertj.core.api.Assertions.assertThat;
3233

@@ -36,7 +37,7 @@
3637
*/
3738
public class EventParsingTests {
3839

39-
private static final LogAccessor logger = new LogAccessor(EventParsingTests.class);
40+
private static final Logger logger = LoggerFactory.getLogger(EventParsingTests.class);
4041

4142
@Test
4243
public void readEvents() throws IOException {

models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/api/tool/AnthropicApiLegacyToolIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
import org.junit.jupiter.api.Test;
2424
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
25+
import org.slf4j.Logger;
26+
import org.slf4j.LoggerFactory;
2527

2628
import org.springframework.ai.anthropic.api.AnthropicApi;
2729
import org.springframework.ai.anthropic.api.AnthropicApi.AnthropicMessage;
@@ -34,7 +36,6 @@
3436
import org.springframework.ai.anthropic.api.tool.XmlHelper.Tools.ToolDescription;
3537
import org.springframework.ai.anthropic.api.tool.XmlHelper.Tools.ToolDescription.Parameter;
3638
import org.springframework.ai.model.ModelOptionsUtils;
37-
import org.springframework.core.log.LogAccessor;
3839
import org.springframework.http.ResponseEntity;
3940

4041
import static org.assertj.core.api.Assertions.assertThat;
@@ -80,7 +81,7 @@ public class AnthropicApiLegacyToolIT {
8081

8182
public static final ConcurrentHashMap<String, Function> FUNCTIONS = new ConcurrentHashMap<>();
8283

83-
private static final LogAccessor logger = new LogAccessor(AnthropicApiLegacyToolIT.class);
84+
private static final Logger logger = LoggerFactory.getLogger(AnthropicApiLegacyToolIT.class);
8485

8586
AnthropicApi anthropicApi = new AnthropicApi(System.getenv("ANTHROPIC_API_KEY"));
8687

models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/api/tool/AnthropicApiToolIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
import org.junit.jupiter.api.Test;
2525
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
26+
import org.slf4j.Logger;
27+
import org.slf4j.LoggerFactory;
2628

2729
import org.springframework.ai.anthropic.api.AnthropicApi;
2830
import org.springframework.ai.anthropic.api.AnthropicApi.AnthropicMessage;
@@ -33,7 +35,6 @@
3335
import org.springframework.ai.anthropic.api.AnthropicApi.Role;
3436
import org.springframework.ai.anthropic.api.AnthropicApi.Tool;
3537
import org.springframework.ai.model.ModelOptionsUtils;
36-
import org.springframework.core.log.LogAccessor;
3738
import org.springframework.http.ResponseEntity;
3839
import org.springframework.util.CollectionUtils;
3940

@@ -55,7 +56,7 @@ public class AnthropicApiToolIT {
5556

5657
public static final ConcurrentHashMap<String, Function> FUNCTIONS = new ConcurrentHashMap<>();
5758

58-
private static final LogAccessor logger = new LogAccessor(AnthropicApiToolIT.class);
59+
private static final Logger logger = LoggerFactory.getLogger(AnthropicApiToolIT.class);
5960

6061
AnthropicApi anthropicApi = new AnthropicApi(System.getenv("ANTHROPIC_API_KEY"));
6162

models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/client/AnthropicChatClientIT.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
2929
import org.junit.jupiter.params.ParameterizedTest;
3030
import org.junit.jupiter.params.provider.ValueSource;
31+
import org.slf4j.Logger;
32+
import org.slf4j.LoggerFactory;
3133
import reactor.core.publisher.Flux;
3234

3335
import org.springframework.ai.anthropic.AnthropicChatOptions;
@@ -48,7 +50,6 @@
4850
import org.springframework.core.convert.support.DefaultConversionService;
4951
import org.springframework.core.io.ClassPathResource;
5052
import org.springframework.core.io.Resource;
51-
import org.springframework.core.log.LogAccessor;
5253
import org.springframework.test.context.ActiveProfiles;
5354
import org.springframework.util.MimeTypeUtils;
5455

@@ -59,7 +60,7 @@
5960
@ActiveProfiles("logging-test")
6061
class AnthropicChatClientIT {
6162

62-
private static final LogAccessor logger = new LogAccessor(AnthropicChatClientIT.class);
63+
private static final Logger logger = LoggerFactory.getLogger(AnthropicChatClientIT.class);
6364

6465
@Autowired
6566
ChatModel chatModel;
@@ -218,7 +219,7 @@ void functionCallTest() {
218219
.content();
219220
// @formatter:on
220221

221-
logger.info("Response: " + response);
222+
logger.info("Response: {}", response);
222223

223224
assertThat(response).contains("30", "10", "15");
224225
}
@@ -236,7 +237,7 @@ void functionCallWithGeneratedDescription() {
236237
.content();
237238
// @formatter:on
238239

239-
logger.info("Response: " + response);
240+
logger.info("Response: {}", response);
240241

241242
assertThat(response).contains("30", "10", "15");
242243
}
@@ -257,7 +258,7 @@ void defaultFunctionCallTest() {
257258
.content();
258259
// @formatter:on
259260

260-
logger.info("Response: " + response);
261+
logger.info("Response: {}", response);
261262

262263
assertThat(response).contains("30", "10", "15");
263264
}
@@ -277,7 +278,7 @@ void streamFunctionCallTest() {
277278
// @formatter:on
278279

279280
String content = response.collectList().block().stream().collect(Collectors.joining());
280-
logger.info("Response: " + content);
281+
logger.info("Response: {}", content);
281282

282283
assertThat(content).contains("30", "10", "15");
283284
}
@@ -339,7 +340,7 @@ void streamingMultiModality() throws IOException {
339340

340341
String content = response.collectList().block().stream().collect(Collectors.joining());
341342

342-
logger.info("Response: " + content);
343+
logger.info("Response: {}", content);
343344
assertThat(content).contains("bananas", "apple");
344345
assertThat(content).containsAnyOf("bowl", "basket");
345346
}

0 commit comments

Comments
 (0)