From 0bd7191806149d246534458267204086eded4c99 Mon Sep 17 00:00:00 2001 From: Enrico Date: Tue, 17 Dec 2024 08:47:06 -0300 Subject: [PATCH] fix: Use slf4j as log manager for jvm --- build.gradle.kts | 8 ++++++-- .../org/hisp/dhis/rules/engine/RuleConditionEvaluator.kt | 2 +- src/jvmMain/kotlin/org/hisp/dhis/rules/Logger.kt | 6 ++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index f76aff8b..545d2f87 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ repositories { maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") } } -version = "3.2.0-SNAPSHOT" +version = "3.2.1-SNAPSHOT" group = "org.hisp.dhis.rules" if (project.hasProperty("removeSnapshotSuffix")) { @@ -67,7 +67,11 @@ kotlin { implementation(kotlin("test")) } } - val jvmMain by getting + val jvmMain by getting { + dependencies { + api("org.slf4j:slf4j-api:1.7.36") + } + } val jvmTest by getting val jsMain by getting { dependencies { diff --git a/src/commonMain/kotlin/org/hisp/dhis/rules/engine/RuleConditionEvaluator.kt b/src/commonMain/kotlin/org/hisp/dhis/rules/engine/RuleConditionEvaluator.kt index 0ef0743f..8a92e746 100644 --- a/src/commonMain/kotlin/org/hisp/dhis/rules/engine/RuleConditionEvaluator.kt +++ b/src/commonMain/kotlin/org/hisp/dhis/rules/engine/RuleConditionEvaluator.kt @@ -220,6 +220,6 @@ internal class RuleConditionEvaluator { } companion object { - private val log = createLogger(RuleConditionEvaluator::class.simpleName!!) + private val log = createLogger("org.hisp.dhis.rules.engine.RuleConditionEvaluator") } } diff --git a/src/jvmMain/kotlin/org/hisp/dhis/rules/Logger.kt b/src/jvmMain/kotlin/org/hisp/dhis/rules/Logger.kt index d1ca11cc..83b1294e 100644 --- a/src/jvmMain/kotlin/org/hisp/dhis/rules/Logger.kt +++ b/src/jvmMain/kotlin/org/hisp/dhis/rules/Logger.kt @@ -1,6 +1,8 @@ package org.hisp.dhis.rules +import org.slf4j.LoggerFactory + actual fun createLogger(className: String): Logger{ - val javaLogger = java.util.logging.Logger.getLogger(className) - return Logger({message -> javaLogger.severe(message)}, {message: String -> javaLogger.fine(message)}) + val javaLogger = LoggerFactory.getLogger(className) + return Logger({message -> javaLogger.error(message)}, {message: String -> javaLogger.debug(message)}) } \ No newline at end of file