Skip to content

Commit

Permalink
feat(backstage/logging): configure logback logging (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixZY authored Oct 9, 2024
2 parents fa54229 + 3509754 commit d3d1d6d
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package se.dansdata.backstage.app

import org.apache.commons.text.WordUtils
import se.dansdata.backstage.utilities.StringUtils
import org.slf4j.LoggerFactory

fun main() {
val tokens = StringUtils.split(MessageUtils.getMessage())
val result = StringUtils.join(tokens)
println(WordUtils.capitalize(result))
val logger = LoggerFactory.getLogger("se.dansdata.backstage.app.AppKt")
logger.info("Backstage initializing...")
}
11 changes: 11 additions & 0 deletions components/api/backstage/app/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%date{STRICT,UTC,en-US} %level [%thread](%logger{36}\) - %msg%replace( [%kvp]){' \[\]', ''}%n</pattern>
</encoder>
</appender>

<root level="debug">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
4 changes: 3 additions & 1 deletion components/api/backstage/buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
plugins {
// Support convention plugins written in Kotlin. Convention plugins are build scripts in 'src/main' that automatically become available as plugins in the main build.
`kotlin-dsl`
}

Expand All @@ -12,4 +11,7 @@ dependencies {
implementation(libs.kotlin.gradle.plugin)
implementation(libs.ktfmt.gradle.plugin)
implementation(libs.detekt.gradle.plugin)

// https://github.com/gradle/gradle/issues/15383
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
}
5 changes: 1 addition & 4 deletions components/api/backstage/buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
dependencyResolutionManagement {
// Reuse version catalog from the main build.
versionCatalogs {
create("libs", { from(files("../gradle/libs.versions.toml")) })
}
versionCatalogs { create("libs") { from(files("../gradle/libs.versions.toml")) } }
}

rootProject.name = "buildSrc"
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import com.ncorti.ktfmt.gradle.tasks.*
import com.ncorti.ktfmt.gradle.tasks.KtfmtFormatTask
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
import org.gradle.accessors.dm.LibrariesForLibs

plugins {
// Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin.
Expand All @@ -14,12 +15,17 @@ repositories {
mavenCentral()
}

val libs = the<LibrariesForLibs>()

dependencies {
constraints {
// Define dependency versions as constraints
implementation("org.apache.commons:commons-text:1.11.0")
}

implementation(libs.logback.core)
implementation(libs.logback.classic)

// Use JUnit Jupiter for testing.
testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")

Expand Down
3 changes: 3 additions & 0 deletions components/api/backstage/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
[versions]
detekt-gradle-plugin = "1.23.7"
logback = "1.5.8"
kotlin-gradle-plugin = "1.9.22"
ktfmt-gradle-plugin = "0.20.1"

[libraries]
detekt-gradle-plugin = { module = "io.gitlab.arturbosch.detekt:io.gitlab.arturbosch.detekt.gradle.plugin", version.ref = "detekt-gradle-plugin" }
logback-core = { module = "ch.qos.logback:logback-core", version.ref="logback" }
logback-classic = { module = "ch.qos.logback:logback-classic", version.ref="logback" }
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin-gradle-plugin" }
ktfmt-gradle-plugin = { module = "com.ncorti.ktfmt.gradle:plugin", version.ref = "ktfmt-gradle-plugin" }

0 comments on commit d3d1d6d

Please sign in to comment.