Skip to content
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

[Feature Request]: Add error method with varargs and Throwable in Logger interface #400

Open
ThinkPeace opened this issue Mar 1, 2024 · 0 comments

Comments

@ThinkPeace
Copy link

ThinkPeace commented Mar 1, 2024

Feature request
I am requesting a feature where the logger interface is extended to have an error method that accepts varargs along with a Throwable.

Motivation
Currently, the error method accepts either a message with varargs or a message with a Throwable. There isn't a method that accepts both combined. This leads to a situation where developers are forced to combine messages and/or params with error objects manually, which can lead to loss of stack trace information or awkward workarounds.

Suggested Solution
Add the following method to the Logger interface:

void error(Throwable tString format, Object... arguments);

Usage Example
This allows the user to log an error with formatting options as well as attaching an exception stack trace like so:

logger.error(throwable, "Something went wrong with the value: {} {}", value1, value2);

I believe this enhancement will make the API more flexible and user-friendly when dealing with common logging scenarios that involve both parameters and exceptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant