Skip to content

Commit

Permalink
Use Khronicle for logging (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
twyatt authored Jun 12, 2024
1 parent d903a60 commit 88734c1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions compile/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ kotlin {
}

dependencies {
implementation(project(":annotations"))
implementation(project(":stubs"))
implementation(libs.khronicle)
implementation(libs.kotlinpoet)
implementation(libs.ksp.api)
implementation(libs.tuulbox.logging)
implementation(project(":annotations"))
implementation(project(":stubs"))
testImplementation(kotlin("test-junit"))
testImplementation(libs.assertj)
testImplementation(libs.ksp.testing)
Expand Down
2 changes: 1 addition & 1 deletion compile/src/main/kotlin/ExerciseProcessor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.juul.exercise.compile.read.asReceiver
import com.juul.exercise.compile.read.findDependencies
import com.juul.exercise.compile.read.findParameters
import com.juul.exercise.compile.write.ExerciseWriter
import com.juul.tuulbox.logging.Log
import com.juul.khronicle.Log

internal class ExerciseProcessor(
private val codeGenerator: CodeGenerator,
Expand Down
4 changes: 2 additions & 2 deletions compile/src/main/kotlin/ExerciseProcessorProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package com.juul.exercise.compile
import com.google.devtools.ksp.processing.SymbolProcessor
import com.google.devtools.ksp.processing.SymbolProcessorEnvironment
import com.google.devtools.ksp.processing.SymbolProcessorProvider
import com.juul.tuulbox.logging.Log
import com.juul.khronicle.Log

public class ExerciseProcessorProvider : SymbolProcessorProvider {
override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor {
Log.dispatcher.install(KspTuulboxLogger(environment.logger))
Log.dispatcher.install(KspKhronicleLogger(environment.logger))
return ExerciseProcessor(environment.codeGenerator)
}
}
10 changes: 5 additions & 5 deletions compile/src/main/kotlin/Logging.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package com.juul.exercise.compile

import com.google.devtools.ksp.processing.KSPLogger
import com.google.devtools.ksp.symbol.KSNode
import com.juul.tuulbox.logging.Key
import com.juul.tuulbox.logging.Logger
import com.juul.tuulbox.logging.ReadMetadata
import com.juul.khronicle.Key
import com.juul.khronicle.Logger
import com.juul.khronicle.ReadMetadata

internal object Node : Key<KSNode>

internal class KspTuulboxLogger(
internal class KspKhronicleLogger(
private val backend: KSPLogger,
) : Logger {

Expand Down Expand Up @@ -47,5 +47,5 @@ internal class KspTuulboxLogger(

override fun hashCode(): Int = backend.hashCode()

override fun equals(other: Any?): Boolean = other is KspTuulboxLogger && backend == other.backend
override fun equals(other: Any?): Boolean = other is KspKhronicleLogger && backend == other.backend
}
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ kotlin = "2.0.0"

[libraries]
assertj = { module = "org.assertj:assertj-core", version = "3.26.0" }
kotlinpoet = { module = "com.squareup:kotlinpoet", version = "1.17.0" }
khronicle = { module = "com.juul.khronicle:khronicle-core", version = "0.3.0" }
kotlin-parcelize-runtime = { module = "org.jetbrains.kotlin:kotlin-parcelize-runtime", version.ref = "kotlin" }
kotlinpoet = { module = "com.squareup:kotlinpoet", version = "1.17.0" }
ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version = "2.0.0-1.0.22" }
ksp-testing = { module = "com.github.tschuchortdev:kotlin-compile-testing-ksp", version = "1.6.0" }
robolectric = { module = "org.robolectric:robolectric", version = "4.12.2" }
tuulbox-logging = { module = "com.juul.tuulbox:logging", version = "7.2.0" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
Expand Down

0 comments on commit 88734c1

Please sign in to comment.