Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Khronicle for logging #300

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compile/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,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.21" }
ksp-testing = { module = "com.github.tschuchortdev:kotlin-compile-testing-ksp", version = "1.5.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
Loading