spring-projects / spring-projects/spring-ai
SimpleLoggerAdvisor should allow JSON formatting
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 6
Description
I am using a SimpleLoggerAdvisor as follows:
public BookRecommendationService(ChatClient.Builder builder) {
this.chatClient = builder.defaultAdvisors(new SimpleLoggerAdvisor()).build();
}
It works well, except that the JSON snippets in the logs are heard to read:
2024-09-15T22:16:35.519+08:00 DEBUG 28615 --- [spring-ai-samples2] [ main] o.s.a.c.c.advisor.SimpleLoggerAdvisor : response: {"result":{"output":{"messageType":"ASSISTANT",
"metadata":{"refusal":"","finishReason":"STOP","index":0,"id":"chatcmpl-A7kLD5Ez8836Wq9a6RKfqh7d3PJYv","role":"ASSISTANT","messageType":"ASSISTANT"},
"toolCalls":[],"content":"{\n \"author\": \"Bonnie Garmus\",\n \"title\": \"Lessons in Chemistry\"\n}"},"metadata":
{"contentFilterMetadata":null,"finishReason":"STOP"}},`...
It would be nice if there was a way to format the JSON snippets properly in the logs, so it would be more readable and also would not display the '\n' instructions.
Thanks again for the great work!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the SimpleLoggerAdvisor entry point and inspect how its response is written to the logs. Reproduce the escaped JSON output shown in the issue, then determine the formatting behavior needed so nested JSON is readable without literal newline escapes; done means the logged response is clearly formatted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend, observability
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100