Skip to content
This repository has been archived by the owner on Jan 22, 2024. It is now read-only.

Commit

Permalink
Add HttpClient logging
Browse files Browse the repository at this point in the history
  • Loading branch information
SlashNephy committed Feb 27, 2021
1 parent 9015f43 commit 71b7902
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ object Libraries {
const val KtorLocations = "io.ktor:ktor-locations:${Versions.Ktor}"
const val KtorSerialization = "io.ktor:ktor-serialization:${Versions.Ktor}"
const val KtorClientCIO = "io.ktor:ktor-client-cio:${Versions.Ktor}"
const val KtorClientLogging = "io.ktor:ktor-client-logging:${Versions.Ktor}"

const val KMongoCoroutineSerialization = "org.litote.kmongo:kmongo-coroutine-serialization:${Versions.KMongo}"
const val KMongoIdSerialization = "org.litote.kmongo:kmongo-id-serialization:${Versions.KMongo}"
Expand Down Expand Up @@ -84,12 +85,11 @@ kotlin {

named("jvmMain") {
dependencies {
implementation(kotlin("reflect"))

implementation(Libraries.KtorServerCIO)
implementation(Libraries.KtorLocations)
implementation(Libraries.KtorSerialization)
implementation(Libraries.KtorClientCIO)
implementation(Libraries.KtorClientLogging)

implementation(Libraries.KMongoCoroutineSerialization)
implementation(Libraries.KMongoIdSerialization)
Expand Down
13 changes: 13 additions & 0 deletions src/jvmMain/kotlin/blue/starry/stella/worker/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,25 @@ import blue.starry.stella.worker.platform.PixivClient
import io.ktor.client.*
import io.ktor.client.engine.cio.*
import io.ktor.client.features.cookies.*
import io.ktor.client.features.logging.*
import mu.KotlinLogging
import org.litote.kmongo.coroutine.coroutine
import org.litote.kmongo.reactivestreams.KMongo

val StellaHttpClient by lazy {
HttpClient(CIO) {
install(HttpCookies)

Logging {
level = LogLevel.INFO
logger = object : Logger {
private val logger = KotlinLogging.logger("stella.http")

override fun log(message: String) {
logger.trace { message }
}
}
}
}
}

Expand Down

0 comments on commit 71b7902

Please sign in to comment.