From 5be8a762389adc48a81f5fa5311d7932a0600a0e Mon Sep 17 00:00:00 2001 From: Robert Mathew Date: Tue, 16 Jul 2024 19:37:43 +0530 Subject: [PATCH] fix: adding env parameter for logging --- .env | 4 +++- gradle/libs.versions.toml | 2 ++ modules/openid-federation-common/README.md | 12 ++++++++++++ modules/openid-federation-common/build.gradle.kts | 1 + .../com/sphereon/oid/fed/common/logging/Logger.kt | 6 ++++++ 5 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 modules/openid-federation-common/README.md diff --git a/.env b/.env index 34ab61a8..22a460c6 100644 --- a/.env +++ b/.env @@ -1,4 +1,6 @@ DATASOURCE_URL=jdbc:postgresql://localhost:5432/openid-federation-db DATASOURCE_USER=openid-federation-db-user DATASOURCE_PASSWORD=openid-federation-db-password -DATASOURCE_DB=openid-federation-db \ No newline at end of file +DATASOURCE_DB=openid-federation-db + +LOGGING=true \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 19b09680..966c4d06 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -17,6 +17,7 @@ kotlinxSerializationJson = "1.7.0-RC" springboot = "3.3.1" springDependencyManagement = "1.1.5" kermitLogging = "2.0.4" +dotenv-kotlin = "6.4.1" [libraries] kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } @@ -31,6 +32,7 @@ androidx-constraintlayout = { group = "androidx.constraintlayout", name = "const androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" } kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" } kermit-logging = { module = "co.touchlab:kermit", version.ref = "kermitLogging"} +dotenv-kotlin = { group = "io.github.cdimascio", name = "dotenv-kotlin", version.ref = "dotenv-kotlin"} kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect" } springboot-actuator = { group = "org.springframework.boot", name = "spring-boot-starter-actuator" } diff --git a/modules/openid-federation-common/README.md b/modules/openid-federation-common/README.md new file mode 100644 index 00000000..cd400ec4 --- /dev/null +++ b/modules/openid-federation-common/README.md @@ -0,0 +1,12 @@ +# Open Federation common + +
+ +Usage of Logger +``` +Logger.verbose("TAG", "Verbose log") +Logger.debug("TAG", "Debug log") +Logger.info("TAG", "Info log") +Logger.warn("TAG", "Warn log") +Logger.error("TAG", "Error log", exception) +``` \ No newline at end of file diff --git a/modules/openid-federation-common/build.gradle.kts b/modules/openid-federation-common/build.gradle.kts index 678dcc90..40985dc1 100644 --- a/modules/openid-federation-common/build.gradle.kts +++ b/modules/openid-federation-common/build.gradle.kts @@ -53,6 +53,7 @@ kotlin { implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.0") implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.7.0") implementation(libs.kermit.logging) + implementation(libs.dotenv.kotlin) } } val commonTest by getting { diff --git a/modules/openid-federation-common/src/commonMain/kotlin/com/sphereon/oid/fed/common/logging/Logger.kt b/modules/openid-federation-common/src/commonMain/kotlin/com/sphereon/oid/fed/common/logging/Logger.kt index a9669633..f15815b9 100644 --- a/modules/openid-federation-common/src/commonMain/kotlin/com/sphereon/oid/fed/common/logging/Logger.kt +++ b/modules/openid-federation-common/src/commonMain/kotlin/com/sphereon/oid/fed/common/logging/Logger.kt @@ -1,9 +1,15 @@ package com.sphereon.oid.fed.common.logging import co.touchlab.kermit.Logger +//import io.github.cdimascio.dotenv.dotenv object Logger { +// val dotenv = dotenv() +// val isLogging = dotenv["LOGGING"] + + + fun verbose(tag: String, message: String) { Logger.v(tag = tag, messageString = message) }