
Logs outgoing HTTP client requests as reproducible cURL commands, capturing method, URL, headers and body; supports request filtering, sensitive-header sanitization, and custom logger integration.
CurlLogging is a Kotlin Multiplatform Ktor client plugin that logs outgoing requests as reproducible cURL commands.
It is useful when you need to copy an app request into a terminal, share a failing request with another developer, or compare Ktor client behavior with a raw HTTP call.
Add Maven Central:
repositories {
mavenCentral()
}Add the dependency to commonMain:
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.github.5peak2me.kmp:curl-logging:0.0.1")
}
}
}Install CurlLogging in your Ktor HttpClient:
import io.github.speak2me.kmp.curl.logging.CurlLogging
import io.ktor.client.HttpClient
val client = HttpClient {
install(CurlLogging)
}Example output:
curl -X GET 'https://httpbin.org/get' -H 'Accept: */*' -H 'Accept-Charset: UTF-8' -H 'Content-Type: application/json'Use a custom logger when you want to route commands to your own logging system:
import io.github.speak2me.kmp.curl.logging.CurlLogging
import io.ktor.client.HttpClient
import io.ktor.client.plugins.logging.Logger
val client = HttpClient {
install(CurlLogging) {
logger = object : Logger {
override fun log(message: String) {
println(message)
}
}
}
}Filter which requests are logged:
install(CurlLogging) {
filter { request ->
request.url.host == "api.example.com"
}
}Sanitize sensitive headers:
import io.ktor.http.HttpHeaders
install(CurlLogging) {
sanitizeHeader { header ->
header == HttpHeaders.Authorization
}
}Run a quick JVM compile check:
./gradlew :shared:compileKotlinJvmOn Windows:
.\gradlew.bat :shared:compileKotlinJvmCurlLogging is a Kotlin Multiplatform Ktor client plugin that logs outgoing requests as reproducible cURL commands.
It is useful when you need to copy an app request into a terminal, share a failing request with another developer, or compare Ktor client behavior with a raw HTTP call.
Add Maven Central:
repositories {
mavenCentral()
}Add the dependency to commonMain:
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.github.5peak2me.kmp:curl-logging:0.0.1")
}
}
}Install CurlLogging in your Ktor HttpClient:
import io.github.speak2me.kmp.curl.logging.CurlLogging
import io.ktor.client.HttpClient
val client = HttpClient {
install(CurlLogging)
}Example output:
curl -X GET 'https://httpbin.org/get' -H 'Accept: */*' -H 'Accept-Charset: UTF-8' -H 'Content-Type: application/json'Use a custom logger when you want to route commands to your own logging system:
import io.github.speak2me.kmp.curl.logging.CurlLogging
import io.ktor.client.HttpClient
import io.ktor.client.plugins.logging.Logger
val client = HttpClient {
install(CurlLogging) {
logger = object : Logger {
override fun log(message: String) {
println(message)
}
}
}
}Filter which requests are logged:
install(CurlLogging) {
filter { request ->
request.url.host == "api.example.com"
}
}Sanitize sensitive headers:
import io.ktor.http.HttpHeaders
install(CurlLogging) {
sanitizeHeader { header ->
header == HttpHeaders.Authorization
}
}Run a quick JVM compile check:
./gradlew :shared:compileKotlinJvmOn Windows:
.\gradlew.bat :shared:compileKotlinJvm