Skip to content

Kotlin SDK

import { Aside } from ‘@astrojs/starlight/components’;

In the meantime, you can hit the HTTP API directly with any HTTP client:

import kotlinx.serialization.json.*
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
import java.net.URI
fun sendLog(
projectId: String,
bucket: String,
level: String,
message: String,
) {
val body = buildJsonObject {
put("projectId", projectId)
putJsonArray("logs") {
addJsonObject {
put("bucket", bucket)
put("level", level)
put("message", message)
put("timestamp", System.currentTimeMillis())
}
}
}
HttpClient.newHttpClient().send(
HttpRequest.newBuilder()
.uri(URI.create("http://localhost:17655/logs"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body.toString()))
.build(),
HttpResponse.BodyHandlers.ofString()
)
}

The protocol is just POST /logs with JSON. Any HTTP client works.