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

Use Reflection instead of a Stacktrace for HttpClient Logger name #83

Merged
merged 2 commits into from
Oct 18, 2024

Conversation

mitschwimmer
Copy link
Contributor

Hi guys, first of all thanks for sharing Klite!

I stumbled upon a minor potential for improvement in the way the name of a logger is determined in classes derived from TypedHttpClient.
The Kotlin Reflection API can provide you with the name of the instantiated class. You might want to consider the Java StackWalk API in case the change I propose is not providing the name you had in mind for the logger.
Both approaches would avoid constructing a Stacktrace which is typically considered a costly operation on the JVM.

mitschwimmer and others added 2 commits September 25, 2024 15:56
Add test for logger naming in TypedHttpClient

Use Kotlin Reflection instead of an Exceptions Stacktrace

Fix JsonHttpClientTest to assert on JsonHTTPClient name, not test class name
@angryziber angryziber merged commit fe76ec6 into codeborne:main Oct 18, 2024
1 check passed
@angryziber
Copy link
Member

Thanks! I used the StackWalker to actually get the name of the container class (usually it is a real client of some sort that does http requests)

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

Successfully merging this pull request may close these issues.

2 participants