https://kotlinlang.org logo
#ktor
Title
# ktor
z

Zoltan Demant

09/27/2023, 6:07 AM
CallLogging
produces simple and to-the-point log messages:
INFO - 200 OK: POST - /route/ in 2981ms
Is it possible to have something similar for a "regular" HttpClient, i.e. what Id use on Android, or anywhere outside of
embeddedServer
?
s

simon.vergauwen

09/27/2023, 6:19 AM
There is a
Logging
plugin for
HttpClient
but it seems that there is no implementation for
Timber
or
LogCat
z

Zoltan Demant

09/27/2023, 6:33 AM
This is actually what I'm using currently, but the logs are very verbose no matter which level I use.
s

simon.vergauwen

09/27/2023, 6:36 AM
It should also be relatively easy to implement your own logging through
HttpSend
interceptor. https://ktor.io/docs/http-send.html
Copy code
val client = HttpClient(Apache)
client.plugin(HttpSend).intercept { request ->
    val originalCall = execute(request)
    // do logging
    originalCall
}
z

Zoltan Demant

09/27/2023, 8:00 AM
Thanks, that works, but is this such an uncommon request? I feel like someone else surely must feel the same way and want for a simple way to log calls (minus verbosity) without having a standalone implementation? 😅
s

simon.vergauwen

09/27/2023, 8:00 AM
Yes, I agree. I think it's fair to expect a similar
CalLogging
plugin for client.
I think a ticket on YouTrack for this would be good
z

Zoltan Demant

09/27/2023, 8:02 AM
Ill create one later today, will share link here when I do!
🙌 1
Support CallLogging like logging for any HttpClient I guess now we can find out if the community actually wants something like this, I know I sure do! Thanks again for your help 🙏🏽