Fixed that on releases (which is important for desktop app bundles) logs get written to user's home dir

This commit is contained in:
dankito 2024-09-20 02:41:16 +02:00
parent 6a8b913bc4
commit 5d0669c5fe
3 changed files with 18 additions and 1 deletions

View File

@ -124,6 +124,7 @@ kotlin {
implementation(libs.favre.bcrypt) implementation(libs.favre.bcrypt)
implementation(libs.logback) implementation(libs.logback)
implementation(libs.janino)
} }
} }
} }

View File

@ -1,5 +1,19 @@
<configuration> <configuration>
<property name="logDir" value="${user.home}/.bankmeister" /> <!-- For Release, write to the user's home directory -->
<if condition='property("ENV").equalsIgnoreCase("debug")'>
<then>
<property name="logDir" value="${user.dir}/data" /> <!-- For Debug/Development, write to the current directory -->
</then>
</if>
<if condition='property("ENV") == "debug"'>
<then>
<property name="logDir" value="${user.dir}/data" /> <!-- For Debug/Development, write to the current directory -->
</then>
</if>
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender"> <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<encoder> <encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
@ -17,7 +31,7 @@
<timestamp key="bySecond" datePattern="yyyyMMdd'T'HHmmss"/> <timestamp key="bySecond" datePattern="yyyyMMdd'T'HHmmss"/>
<appender name="file" class="ch.qos.logback.core.FileAppender"> <appender name="file" class="ch.qos.logback.core.FileAppender">
<file>data/logs/Bankmeister-${bySecond}.log</file> <file>${logDir}/logs/Bankmeister-${bySecond}.log</file>
<!-- encoders are assigned the type <!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder> <encoder>

View File

@ -12,6 +12,7 @@ favre-bcrypt = "0.10.2"
klf = "1.6.2" klf = "1.6.2"
logback = "1.5.7" logback = "1.5.7"
janino = "3.1.12"
sqlDelight = "2.0.2" sqlDelight = "2.0.2"
@ -45,6 +46,7 @@ favre-bcrypt = { group = "at.favre.lib", name = "bcrypt", version.ref = "favre-b
klf = { group = "net.codinux.log", name = "klf", version.ref = "klf" } klf = { group = "net.codinux.log", name = "klf", version.ref = "klf" }
logback = { group = "ch.qos.logback", name = "logback-classic", version.ref = "logback" } logback = { group = "ch.qos.logback", name = "logback-classic", version.ref = "logback" }
janino = { group = "org.codehaus.janino", name = "janino", version.ref = "janino" }
sqldelight-runtime = { module = "app.cash.sqldelight:runtime", version.ref = "sqlDelight" } sqldelight-runtime = { module = "app.cash.sqldelight:runtime", version.ref = "sqlDelight" }
sqldelight-coroutines-extensions = { module = "app.cash.sqldelight:coroutines-extensions", version.ref = "sqlDelight" } sqldelight-coroutines-extensions = { module = "app.cash.sqldelight:coroutines-extensions", version.ref = "sqlDelight" }