-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(template-st): log StringTemplate compile/runtime errors via SLF4J #3708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2023-2025 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.ai.template.st; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.stringtemplate.v4.STErrorListener; | ||
import org.stringtemplate.v4.misc.STMessage; | ||
|
||
/** | ||
* {@link STErrorListener} implementation that logs errors using SLF4J. | ||
*/ | ||
public class Slf4jStErrorListener implements STErrorListener { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(StTemplateRenderer.class); | ||
|
||
@Override | ||
public void compileTimeError(STMessage msg) { | ||
logger.error("StringTemplate compile error: {}", msg); | ||
} | ||
|
||
@Override | ||
public void runTimeError(STMessage msg) { | ||
logger.error("StringTemplate runtime error: {}", msg); | ||
} | ||
|
||
@Override | ||
public void IOError(STMessage msg) { | ||
logger.error("StringTemplate IO error: {}", msg); | ||
} | ||
|
||
@Override | ||
public void internalError(STMessage msg) { | ||
logger.error("StringTemplate internal error: {}", msg); | ||
} | ||
|
||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please reorganize the imports in the following order:
Also, please avoid using wildcard imports For reference, you can refer to the example in this file: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Additionally, unnecessary tabs have been added. It would be great if you could remove those as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line appears to have an unnecessary line break.