CLOVIS
10/22/2020, 3:30 PMrusshwolf
10/22/2020, 3:54 PMLogLevel.BODY or LogLevel.ALL once https://youtrack.jetbrains.com/issue/KTOR-426 is fixed.CLOVIS
10/22/2020, 9:16 PMMJegorovas
10/23/2020, 10:34 AMclass BodyLoggingInterceptor {
companion object : HttpClientFeature<Nothing, BodyLoggingInterceptor> {
override val key: AttributeKey<BodyLoggingInterceptor> =
AttributeKey("BodyLoggingInterceptor")
override fun prepare(block: Nothing.() -> Unit): BodyLoggingInterceptor =
BodyLoggingInterceptor()
override fun install(feature: BodyLoggingInterceptor, scope: HttpClient) {
scope.sendPipeline.intercept(HttpSendPipeline.Monitoring) {
val body = context.body
if (body is TextContent) {
val content = body.text
for (i in content.indices step 1024) {
Log.d(
"BodyLoggingInterceptor",
content.substring(i, min(content.length, i + 1024))
)
}
}
}
}
}
}
And then just install in the client just as any other feature.CLOVIS
10/23/2020, 6:51 PMLogLevel.ALL does print the BODY but only for JSON requests, I'm trying to debug a Multipart request 😕CLOVIS
10/23/2020, 6:55 PMMJegorovas
10/26/2020, 12:03 PMMultiPartFormDataContent content out of it because it is already processed as List<PreparedPart> at this point, so you'll need some other way to log this.CLOVIS
10/27/2020, 8:34 AMMJegorovas
10/27/2020, 9:49 AMsubmitFormWithBinaryData method to build request you'll need to print your List<PartData> content before passing it to that method. I don't have any other thought at the moment.