diff --git a/service/build.gradle.kts b/service/build.gradle.kts index 988d9897b20..c508c035b9f 100644 --- a/service/build.gradle.kts +++ b/service/build.gradle.kts @@ -70,7 +70,7 @@ dependencies { // Logging implementation("ch.qos.logback.access:logback-access-tomcat") - implementation("io.github.microutils:kotlin-logging-jvm") + implementation("io.github.oshai:kotlin-logging-jvm") implementation("net.logstash.logback:logstash-logback-encoder") // Spring diff --git a/service/codegen/build.gradle.kts b/service/codegen/build.gradle.kts index 222fbfad682..72ce72f5ab8 100644 --- a/service/codegen/build.gradle.kts +++ b/service/codegen/build.gradle.kts @@ -14,7 +14,7 @@ dependencies { testImplementation(platform(project(":evaka-bom"))) implementation(project(":")) - implementation("io.github.microutils:kotlin-logging-jvm") + implementation("io.github.oshai:kotlin-logging-jvm") // Kotlin + core implementation(kotlin("stdlib")) diff --git a/service/codegen/src/main/kotlin/evaka/codegen/Codegen.kt b/service/codegen/src/main/kotlin/evaka/codegen/Codegen.kt index fd303d1feb2..403d1d347c7 100644 --- a/service/codegen/src/main/kotlin/evaka/codegen/Codegen.kt +++ b/service/codegen/src/main/kotlin/evaka/codegen/Codegen.kt @@ -9,6 +9,7 @@ import evaka.codegen.actionenum.generateActionEnumTypes import evaka.codegen.api.TsFile import evaka.codegen.api.TsProject import evaka.codegen.api.generateApiFiles +import io.github.oshai.kotlinlogging.KotlinLogging import java.nio.file.Path import kotlin.io.path.Path import kotlin.io.path.absolute @@ -19,7 +20,6 @@ import kotlin.io.path.readText import kotlin.io.path.relativeTo import kotlin.io.path.writeText import kotlin.system.exitProcess -import mu.KotlinLogging private val logger = KotlinLogging.logger {} @@ -27,7 +27,7 @@ fun generate() { val srcPath = locateFrontendSrcDirectory() val generatedPath = srcPath / "lib-common" / "generated" if (!generatedPath.exists()) { - logger.error("Root path $generatedPath does not exist -> aborting") + logger.error { "Root path $generatedPath does not exist -> aborting" } exitProcess(1) } @@ -66,9 +66,9 @@ fun check() { val currentContent = path.readText() val relativePath = path.relativeTo(srcPath) if (content == currentContent) { - logger.info("Generated api files up to date ($relativePath)") + logger.info { "Generated api files up to date ($relativePath)" } } else { - logger.error("Generated api files were not up to date ($relativePath)") + logger.error { "Generated api files were not up to date ($relativePath)" } exitProcess(1) } } diff --git a/service/codegen/src/main/kotlin/evaka/codegen/Languages.kt b/service/codegen/src/main/kotlin/evaka/codegen/Languages.kt index 627f345ed10..2e1a35f077e 100644 --- a/service/codegen/src/main/kotlin/evaka/codegen/Languages.kt +++ b/service/codegen/src/main/kotlin/evaka/codegen/Languages.kt @@ -6,18 +6,18 @@ package evaka.codegen import fi.espoo.evaka.shared.domain.ISO_LANGUAGES_SUBSET import fi.espoo.evaka.shared.domain.IsoLanguage +import io.github.oshai.kotlinlogging.KotlinLogging import java.nio.file.Path import kotlin.io.path.readText import kotlin.io.path.writeText import kotlin.system.exitProcess -import mu.KotlinLogging import org.intellij.lang.annotations.Language private val logger = KotlinLogging.logger {} fun generateLanguages(target: Path) { target.writeText(sequenceOf(fileHeader, languageFileBody()).joinToString("\n")) - logger.info("Generated $target") + logger.info { "Generated $target" } } private fun languageFileBody(): String { @@ -42,7 +42,7 @@ private fun IsoLanguage.toTypescript(): String = fun checkLanguages(target: Path) { if (languageFileBody() != target.readText().skipFileHeader()) { - logger.error("File is not up to date: $target") + logger.error { "File is not up to date: $target" } exitProcess(1) } } diff --git a/service/codegen/src/main/kotlin/evaka/codegen/actionenum/Cli.kt b/service/codegen/src/main/kotlin/evaka/codegen/actionenum/Cli.kt index dde05c068e0..7e1c4e4ff6e 100644 --- a/service/codegen/src/main/kotlin/evaka/codegen/actionenum/Cli.kt +++ b/service/codegen/src/main/kotlin/evaka/codegen/actionenum/Cli.kt @@ -4,11 +4,11 @@ package evaka.codegen.actionenum +import io.github.oshai.kotlinlogging.KotlinLogging import java.nio.file.Path import kotlin.io.path.div import kotlin.io.path.readText import kotlin.system.exitProcess -import mu.KotlinLogging private val logger = KotlinLogging.logger {} @@ -17,15 +17,15 @@ fun checkGeneratedActionEnumTypes(target: Path) { for (definition in generatedFiles) { val file = target / definition.name if (definition.generate() != file.readText()) { - logger.error("File is not up to date: $file") + logger.error { "File is not up to date: $file" } errors += 1 } } if (errors > 0) { - logger.error("$errors were not up to date") + logger.error { "$errors were not up to date" } exitProcess(1) } else { - logger.info("All files up to date") + logger.info { "All files up to date" } } } @@ -33,6 +33,6 @@ fun generateActionEnumTypes(target: Path) { for (definition in generatedFiles) { val file = target / definition.name definition.generateTo(file) - logger.info("Generated $file") + logger.info { "Generated $file" } } } diff --git a/service/codegen/src/main/kotlin/evaka/codegen/api/ApiFiles.kt b/service/codegen/src/main/kotlin/evaka/codegen/api/ApiFiles.kt index 32035aa6a41..94a7f41cc7c 100644 --- a/service/codegen/src/main/kotlin/evaka/codegen/api/ApiFiles.kt +++ b/service/codegen/src/main/kotlin/evaka/codegen/api/ApiFiles.kt @@ -8,10 +8,10 @@ import evaka.codegen.fileHeader import fi.espoo.evaka.shared.auth.AuthenticatedUser import fi.espoo.evaka.shared.utils.letIf import fi.espoo.evaka.shared.utils.mapOfNotNullValues +import io.github.oshai.kotlinlogging.KotlinLogging import kotlin.reflect.KClass import kotlin.reflect.jvm.jvmName import kotlin.reflect.typeOf -import mu.KotlinLogging import org.springframework.web.util.UriComponentsBuilder private val logger = KotlinLogging.logger {} @@ -181,7 +181,9 @@ fun generateApiTypes( ): String { val conflicts = namedTypes.groupBy { it.name }.filter { it.value.size > 1 } conflicts.forEach { (name, conflictingClasses) -> - logger.error("Multiple Kotlin classes map to $name: ${conflictingClasses.map { it.name }}") + logger.error { + "Multiple Kotlin classes map to $name: ${conflictingClasses.map { it.name }}" + } } if (conflicts.isNotEmpty()) { error("${conflicts.size} classes are generated by more than one Kotlin class") diff --git a/service/evaka-bom/build.gradle.kts b/service/evaka-bom/build.gradle.kts index 447c0a209d3..d7f51708ccd 100644 --- a/service/evaka-bom/build.gradle.kts +++ b/service/evaka-bom/build.gradle.kts @@ -21,7 +21,7 @@ dependencies { api("com.google.guava:guava:33.4.0-jre") api("com.networknt:json-schema-validator:1.5.0") api("com.zaxxer:HikariCP:6.2.1") - api("io.github.microutils:kotlin-logging-jvm:3.0.5") + api("io.github.oshai:kotlin-logging-jvm:7.0.3") api("io.kotest:kotest-property:5.9.1") api("io.mockk:mockk:1.13.13") api("jakarta.annotation:jakarta.annotation-api:3.0.0") diff --git a/service/service-lib/build.gradle.kts b/service/service-lib/build.gradle.kts index 967d13046dc..1f00ea1c91b 100644 --- a/service/service-lib/build.gradle.kts +++ b/service/service-lib/build.gradle.kts @@ -21,7 +21,7 @@ dependencies { testImplementation(kotlin("test-junit5")) // Logging - implementation("io.github.microutils:kotlin-logging-jvm") + implementation("io.github.oshai:kotlin-logging-jvm") implementation("net.logstash.logback:logstash-logback-encoder") // Spring diff --git a/service/service-lib/src/main/kotlin/fi/espoo/voltti/auth/JwtTokenDecoder.kt b/service/service-lib/src/main/kotlin/fi/espoo/voltti/auth/JwtTokenDecoder.kt index dbd22ddd5b7..52fa881c2f0 100644 --- a/service/service-lib/src/main/kotlin/fi/espoo/voltti/auth/JwtTokenDecoder.kt +++ b/service/service-lib/src/main/kotlin/fi/espoo/voltti/auth/JwtTokenDecoder.kt @@ -11,7 +11,7 @@ import jakarta.servlet.FilterChain import jakarta.servlet.http.HttpFilter import jakarta.servlet.http.HttpServletRequest import jakarta.servlet.http.HttpServletResponse -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging // RFC6750 - The OAuth 2.0 Authorization Framework: Bearer Token Usage // Authorization Request Header Field diff --git a/service/service-lib/src/main/kotlin/fi/espoo/voltti/logging/loggers/AppMiscLoggers.kt b/service/service-lib/src/main/kotlin/fi/espoo/voltti/logging/loggers/AppMiscLoggers.kt index 23772bae143..af4d5e56ef6 100644 --- a/service/service-lib/src/main/kotlin/fi/espoo/voltti/logging/loggers/AppMiscLoggers.kt +++ b/service/service-lib/src/main/kotlin/fi/espoo/voltti/logging/loggers/AppMiscLoggers.kt @@ -4,35 +4,42 @@ package fi.espoo.voltti.logging.loggers -import mu.KLogger +import io.github.oshai.kotlinlogging.KLogger import net.logstash.logback.argument.StructuredArguments /** * Extensions to allow adding meta-fields to app-misc logs without requiring StructuredArguments * wrapper and an unnecessary dependency to net.logstash.logback. */ -fun KLogger.trace(meta: Map, m: () -> Any?) { - if (isTraceEnabled) trace(m.toStringSafe(), metaToLoggerArgs(meta)) +fun KLogger.trace(meta: Map, m: () -> Any?) = atTrace { + message = m.toStringSafe() + arguments = arrayOf(metaToLoggerArgs(meta)) } -fun KLogger.debug(meta: Map, m: () -> Any?) { - if (isDebugEnabled) debug(m.toStringSafe(), metaToLoggerArgs(meta)) +fun KLogger.debug(meta: Map, m: () -> Any?) = atDebug { + message = m.toStringSafe() + arguments = arrayOf(metaToLoggerArgs(meta)) } -fun KLogger.info(meta: Map, m: () -> Any?) { - if (isInfoEnabled) info(m.toStringSafe(), metaToLoggerArgs(meta)) +fun KLogger.info(meta: Map, m: () -> Any?) = atInfo { + message = m.toStringSafe() + arguments = arrayOf(metaToLoggerArgs(meta)) } -fun KLogger.warn(meta: Map, m: () -> Any?) { - if (isWarnEnabled) warn(m.toStringSafe(), metaToLoggerArgs(meta)) +fun KLogger.warn(meta: Map, m: () -> Any?) = atWarn { + message = m.toStringSafe() + arguments = arrayOf(metaToLoggerArgs(meta)) } -fun KLogger.error(meta: Map, m: () -> Any?) { - if (isErrorEnabled) error(m.toStringSafe(), metaToLoggerArgs(meta)) +fun KLogger.error(meta: Map, m: () -> Any?) = atError { + message = m.toStringSafe() + arguments = arrayOf(metaToLoggerArgs(meta)) } -fun KLogger.error(error: Any, meta: Map, m: () -> Any?) { - if (isErrorEnabled) error(m.toStringSafe(), metaToLoggerArgs(meta), error) +fun KLogger.error(error: Throwable, meta: Map, m: () -> Any?) = atError { + message = m.toStringSafe() + cause = error + arguments = arrayOf(metaToLoggerArgs(meta)) } private fun metaToLoggerArgs(meta: Map) = diff --git a/service/service-lib/src/main/kotlin/fi/espoo/voltti/logging/loggers/AuditLogger.kt b/service/service-lib/src/main/kotlin/fi/espoo/voltti/logging/loggers/AuditLogger.kt index aa0f7575ab6..5b8f37f5843 100644 --- a/service/service-lib/src/main/kotlin/fi/espoo/voltti/logging/loggers/AuditLogger.kt +++ b/service/service-lib/src/main/kotlin/fi/espoo/voltti/logging/loggers/AuditLogger.kt @@ -4,21 +4,19 @@ package fi.espoo.voltti.logging.loggers -import mu.KLogger +import io.github.oshai.kotlinlogging.KLogger +import io.github.oshai.kotlinlogging.KMarkerFactory +import io.github.oshai.kotlinlogging.Marker import net.logstash.logback.argument.StructuredArguments -import org.slf4j.Marker -import org.slf4j.MarkerFactory -val AUDIT_MARKER: Marker = MarkerFactory.getMarker("AUDIT_EVENT") +val AUDIT_MARKER: Marker = KMarkerFactory.getMarker("AUDIT_EVENT") -fun KLogger.audit(m: () -> Any?) { - audit(emptyMap(), m) -} +fun KLogger.audit(m: () -> Any?) = audit(emptyMap(), m) -fun KLogger.audit(t: Throwable, m: () -> Any?) { - if (isWarnEnabled) warn(AUDIT_MARKER, m.toStringSafe(), t) -} +fun KLogger.audit(t: Throwable, m: () -> Any?) = warn(t, AUDIT_MARKER, m) -fun KLogger.audit(args: Map, m: () -> Any?) { - if (isWarnEnabled) warn(AUDIT_MARKER, m.toStringSafe(), StructuredArguments.entries(args)) -} +fun KLogger.audit(args: Map, m: () -> Any?) = + atWarn(AUDIT_MARKER) { + message = m.toStringSafe() + arguments = arrayOf(StructuredArguments.entries(args)) + } diff --git a/service/service-lib/src/main/kotlin/fi/espoo/voltti/logging/loggers/VTJLogger.kt b/service/service-lib/src/main/kotlin/fi/espoo/voltti/logging/loggers/VTJLogger.kt index 58b38644fbe..d7c8c3cac9a 100644 --- a/service/service-lib/src/main/kotlin/fi/espoo/voltti/logging/loggers/VTJLogger.kt +++ b/service/service-lib/src/main/kotlin/fi/espoo/voltti/logging/loggers/VTJLogger.kt @@ -4,24 +4,27 @@ package fi.espoo.voltti.logging.loggers -import mu.KLogger +import io.github.oshai.kotlinlogging.KLogger +import io.github.oshai.kotlinlogging.KMarkerFactory import net.logstash.logback.argument.StructuredArguments -import org.slf4j.MarkerFactory -private val auditMarker = MarkerFactory.getMarker("VTJ_EVENT") +private val auditMarker = KMarkerFactory.getMarker("VTJ_EVENT") -fun KLogger.auditVTJ(m: () -> Any?) { - auditVTJ(emptyMap(), m) -} +fun KLogger.auditVTJ(m: () -> Any?) = auditVTJ(emptyMap(), m) -fun KLogger.auditVTJ(args: Map, m: () -> Any?) { - if (isWarnEnabled) warn(auditMarker, m.toStringSafe(), StructuredArguments.entries(args)) -} +fun KLogger.auditVTJ(args: Map, m: () -> Any?) = + atWarn(auditMarker) { + message = m.toStringSafe() + arguments = arrayOf(StructuredArguments.entries(args)) + } fun KLogger.auditVTJ(t: Throwable, m: () -> Any?) { auditVTJ(emptyMap(), t, m) } -fun KLogger.auditVTJ(args: Map, t: Throwable, m: () -> Any?) { - if (isWarnEnabled) warn(auditMarker, m.toStringSafe(), t, StructuredArguments.entries(args)) -} +fun KLogger.auditVTJ(args: Map, t: Throwable, m: () -> Any?) = + atWarn(auditMarker) { + message = m.toStringSafe() + cause = t + arguments = arrayOf(StructuredArguments.entries(args)) + } diff --git a/service/service-lib/src/test/kotlin/fi/espoo/voltti/logging/logback/AppenderTest.kt b/service/service-lib/src/test/kotlin/fi/espoo/voltti/logging/logback/AppenderTest.kt index e9186199c53..81d92ea7ba7 100644 --- a/service/service-lib/src/test/kotlin/fi/espoo/voltti/logging/logback/AppenderTest.kt +++ b/service/service-lib/src/test/kotlin/fi/espoo/voltti/logging/logback/AppenderTest.kt @@ -5,10 +5,10 @@ package fi.espoo.voltti.logging.logback import fi.espoo.voltti.logging.loggers.info +import io.github.oshai.kotlinlogging.KLogger +import io.github.oshai.kotlinlogging.KMarkerFactory +import io.github.oshai.kotlinlogging.KotlinLogging import java.util.UUID -import mu.KLogger -import mu.KMarkerFactory -import mu.KotlinLogging import net.logstash.logback.argument.StructuredArguments import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.AfterEach @@ -19,7 +19,10 @@ private val logger = KotlinLogging.logger {} private val auditMarker = KMarkerFactory.getMarker("AUDIT_EVENT") private fun KLogger.audit(msg: String, args: Map) = - info(auditMarker, msg, StructuredArguments.e(args)) + atInfo(auditMarker) { + message = msg + arguments = arrayOf(StructuredArguments.e(args)) + } class AppenderTest { private val meta = TestMeta.random() @@ -55,12 +58,16 @@ class AppenderTest { val event1 = DefaultEvent(userIdHash) val exception = TestException() - logger.error(event1.message, StructuredArguments.e(mapOf("meta" to meta)), exception) + logger.atError { + message = event1.message + cause = exception + arguments = arrayOf(StructuredArguments.e(mapOf("meta" to meta))) + } it.assertDefault().containsExactly(event1.tuple()) it.withLatestDefault { actual -> defaultErrorAssertions(actual, meta, exception) } val event2 = DefaultEvent(userIdHash) - logger.info(event2.message) + logger.info { event2.message } it.assertDefault().containsExactly(event1.tuple(), event2.tuple()) it.withLatestDefault { actual -> defaultInfoAssertions(actual) } @@ -75,7 +82,11 @@ class AppenderTest { val event1 = DefaultEvent(userIdHash) val exception = TestExceptionSensitive() - logger.error(event1.message, StructuredArguments.e(mapOf("meta" to meta)), exception) + logger.atError { + message = event1.message + cause = exception + arguments = arrayOf(StructuredArguments.e(mapOf("meta" to meta))) + } it.assertSanitized().containsExactly(event1.tuple()) it.withLatestSanitized { actual -> defaultErrorAssertions(actual, meta, exception) @@ -84,7 +95,7 @@ class AppenderTest { } val event2 = DefaultEvent(userIdHash) - logger.info(event2.message) + logger.info { event2.message } it.assertSanitized().containsExactly(event1.tuple(), event2.tuple()) it.withLatestSanitized { actual -> defaultInfoAssertions(actual) } diff --git a/service/service-lib/src/test/kotlin/fi/espoo/voltti/logging/loggers/AppMiscLoggersTest.kt b/service/service-lib/src/test/kotlin/fi/espoo/voltti/logging/loggers/AppMiscLoggersTest.kt index 943932c87e6..07a685dccc1 100644 --- a/service/service-lib/src/test/kotlin/fi/espoo/voltti/logging/loggers/AppMiscLoggersTest.kt +++ b/service/service-lib/src/test/kotlin/fi/espoo/voltti/logging/loggers/AppMiscLoggersTest.kt @@ -12,29 +12,32 @@ import fi.espoo.voltti.logging.utils.clearTestMessages import fi.espoo.voltti.logging.utils.getTestAppender import fi.espoo.voltti.logging.utils.getTestMessages import fi.espoo.voltti.logging.utils.setupTestAppender +import io.github.oshai.kotlinlogging.DelegatingKLogger import kotlin.test.assertEquals -import mu.KLogger -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KLogger +import io.github.oshai.kotlinlogging.KotlinLogging import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test private val logger = KotlinLogging.logger {}.also(KLogger::setupTestAppender) +private fun KLogger.underlyingLogger(): Logger = + (this as DelegatingKLogger<*>).underlyingLogger as Logger private const val message = "test message" -private val initialLogLevel = (logger.underlyingLogger as Logger).level +private val initialLogLevel = logger.underlyingLogger().level class AppMiscLoggersTest { @BeforeEach fun before() { // To avoid noise in other tests, just raise the log level for these tests that require // TRACE - (logger.underlyingLogger as Logger).level = Level.TRACE + (logger.underlyingLogger()).level = Level.TRACE } @AfterEach fun clear() { logger.clearTestMessages() - (logger.underlyingLogger as Logger).level = initialLogLevel + (logger.underlyingLogger()).level = initialLogLevel } @Test diff --git a/service/service-lib/src/test/kotlin/fi/espoo/voltti/logging/loggers/AuditLoggerTest.kt b/service/service-lib/src/test/kotlin/fi/espoo/voltti/logging/loggers/AuditLoggerTest.kt index 8efdb23a912..37a92ff13b4 100644 --- a/service/service-lib/src/test/kotlin/fi/espoo/voltti/logging/loggers/AuditLoggerTest.kt +++ b/service/service-lib/src/test/kotlin/fi/espoo/voltti/logging/loggers/AuditLoggerTest.kt @@ -11,8 +11,8 @@ import fi.espoo.voltti.logging.utils.getTestAppender import fi.espoo.voltti.logging.utils.getTestMessages import fi.espoo.voltti.logging.utils.setupTestAppender import kotlin.test.assertEquals -import mu.KLogger -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KLogger +import io.github.oshai.kotlinlogging.KotlinLogging import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Test @@ -46,7 +46,7 @@ class AuditLoggerTest { logger.audit(emptyMap()) { message } logger.getTestAppender().getEvents().forEach { event -> - assertEquals(listOf(AUDIT_MARKER), event.markerList) + assertEquals(listOf(AUDIT_MARKER.getName()), event.markerList.map { it.name }) } } diff --git a/service/service-lib/src/test/kotlin/fi/espoo/voltti/logging/loggers/TestAppenderTest.kt b/service/service-lib/src/test/kotlin/fi/espoo/voltti/logging/loggers/TestAppenderTest.kt index 8c4891bfaa9..24589873f99 100644 --- a/service/service-lib/src/test/kotlin/fi/espoo/voltti/logging/loggers/TestAppenderTest.kt +++ b/service/service-lib/src/test/kotlin/fi/espoo/voltti/logging/loggers/TestAppenderTest.kt @@ -8,10 +8,10 @@ import fi.espoo.voltti.logging.utils.clearTestMessages import fi.espoo.voltti.logging.utils.getJson import fi.espoo.voltti.logging.utils.getTestMessages import fi.espoo.voltti.logging.utils.setupTestAppender +import io.github.oshai.kotlinlogging.KLogger +import io.github.oshai.kotlinlogging.KotlinLogging import kotlin.test.assertEquals import kotlin.test.assertTrue -import mu.KLogger -import mu.KotlinLogging import net.logstash.logback.argument.StructuredArguments import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Test @@ -53,7 +53,10 @@ class TestAppenderTest { @Test fun `test rendering structured arguments to json`() { - logger.info("message", StructuredArguments.entries(mapOf("one" to "1", "two" to "2"))) + logger.atInfo { + message = "message" + arguments = arrayOf(StructuredArguments.entries(mapOf("one" to "1", "two" to "2"))) + } JSONAssert.assertEquals("""{ "one": "1", "two": "2"}""", logger.getJson(), true) } } diff --git a/service/service-lib/src/test/kotlin/fi/espoo/voltti/logging/utils/TestAppender.kt b/service/service-lib/src/test/kotlin/fi/espoo/voltti/logging/utils/TestAppender.kt index de6ee3219b9..14b311d52ab 100644 --- a/service/service-lib/src/test/kotlin/fi/espoo/voltti/logging/utils/TestAppender.kt +++ b/service/service-lib/src/test/kotlin/fi/espoo/voltti/logging/utils/TestAppender.kt @@ -9,9 +9,10 @@ import ch.qos.logback.classic.spi.ILoggingEvent import ch.qos.logback.core.AppenderBase import com.fasterxml.jackson.core.JsonFactory import com.fasterxml.jackson.databind.json.JsonMapper +import io.github.oshai.kotlinlogging.DelegatingKLogger import java.io.PrintWriter import java.io.StringWriter -import mu.KLogger +import io.github.oshai.kotlinlogging.KLogger import net.logstash.logback.argument.StructuredArgument import org.json.JSONObject @@ -62,12 +63,14 @@ class TestAppender : AppenderBase() { } } +private fun KLogger.underlyingLogger(): Logger = + (this as DelegatingKLogger<*>).underlyingLogger as Logger fun KLogger.setupTestAppender() { - (this.underlyingLogger as Logger).addAppender(TestAppender()) + (this.underlyingLogger()).addAppender(TestAppender()) } fun KLogger.getTestAppender(): TestAppender = - (this.underlyingLogger as Logger).getAppender(appenderName) as TestAppender + (this.underlyingLogger()).getAppender(appenderName) as TestAppender fun KLogger.getTestMessages(): List = this.getTestAppender().getMessages() diff --git a/service/src/integrationTest/kotlin/fi/espoo/evaka/assistanceneed/decision/AssistanceNeedDecisionIntegrationTest.kt b/service/src/integrationTest/kotlin/fi/espoo/evaka/assistanceneed/decision/AssistanceNeedDecisionIntegrationTest.kt index fdaf6e822db..5b9f896f974 100644 --- a/service/src/integrationTest/kotlin/fi/espoo/evaka/assistanceneed/decision/AssistanceNeedDecisionIntegrationTest.kt +++ b/service/src/integrationTest/kotlin/fi/espoo/evaka/assistanceneed/decision/AssistanceNeedDecisionIntegrationTest.kt @@ -41,6 +41,7 @@ import fi.espoo.evaka.testDaycare2 import fi.espoo.evaka.testDecisionMaker_1 import fi.espoo.evaka.testDecisionMaker_3 import fi.espoo.evaka.unitSupervisorOfTestDaycare +import io.github.oshai.kotlinlogging.KotlinLogging import java.io.File import java.io.FileOutputStream import java.time.LocalDate @@ -49,7 +50,6 @@ import kotlin.test.assertContains import kotlin.test.assertEquals import kotlin.test.assertNotNull import kotlin.test.assertNull -import mu.KotlinLogging import org.assertj.core.groups.Tuple import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test diff --git a/service/src/integrationTest/kotlin/fi/espoo/evaka/assistanceneed/decision/AssistanceNeedPreschoolDecisionIntegrationTest.kt b/service/src/integrationTest/kotlin/fi/espoo/evaka/assistanceneed/decision/AssistanceNeedPreschoolDecisionIntegrationTest.kt index 39db74b3f95..20cc63a5b1f 100644 --- a/service/src/integrationTest/kotlin/fi/espoo/evaka/assistanceneed/decision/AssistanceNeedPreschoolDecisionIntegrationTest.kt +++ b/service/src/integrationTest/kotlin/fi/espoo/evaka/assistanceneed/decision/AssistanceNeedPreschoolDecisionIntegrationTest.kt @@ -48,6 +48,7 @@ import fi.espoo.evaka.testDaycare2 import fi.espoo.evaka.testDecisionMaker_1 import fi.espoo.evaka.testDecisionMaker_3 import fi.espoo.evaka.unitSupervisorOfTestDaycare +import io.github.oshai.kotlinlogging.KotlinLogging import java.io.File import java.io.FileOutputStream import java.time.LocalDate @@ -55,7 +56,6 @@ import java.util.* import kotlin.test.assertContains import kotlin.test.assertEquals import kotlin.test.assertNotNull -import mu.KotlinLogging import org.assertj.core.api.Assertions.assertThat import org.assertj.core.groups.Tuple import org.junit.jupiter.api.BeforeEach diff --git a/service/src/integrationTest/kotlin/fi/espoo/evaka/dvv/MockDvvModificationsService.kt b/service/src/integrationTest/kotlin/fi/espoo/evaka/dvv/MockDvvModificationsService.kt index 9d0d73820a5..73b9536b9d4 100644 --- a/service/src/integrationTest/kotlin/fi/espoo/evaka/dvv/MockDvvModificationsService.kt +++ b/service/src/integrationTest/kotlin/fi/espoo/evaka/dvv/MockDvvModificationsService.kt @@ -4,7 +4,7 @@ package fi.espoo.evaka.dvv -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.springframework.context.annotation.Profile import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PathVariable diff --git a/service/src/integrationTest/kotlin/fi/espoo/evaka/koski/MockKoskiEndpoint.kt b/service/src/integrationTest/kotlin/fi/espoo/evaka/koski/MockKoskiEndpoint.kt index 98ddcab828d..5646183e2c9 100644 --- a/service/src/integrationTest/kotlin/fi/espoo/evaka/koski/MockKoskiEndpoint.kt +++ b/service/src/integrationTest/kotlin/fi/espoo/evaka/koski/MockKoskiEndpoint.kt @@ -7,10 +7,10 @@ package fi.espoo.evaka.koski import com.fasterxml.jackson.databind.json.JsonMapper import com.google.common.collect.Multimaps import com.google.common.collect.SetMultimap +import io.github.oshai.kotlinlogging.KotlinLogging import java.util.concurrent.locks.ReentrantLock import kotlin.concurrent.withLock import kotlin.random.Random -import mu.KotlinLogging import org.springframework.http.HttpMethod import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity diff --git a/service/src/integrationTest/kotlin/fi/espoo/evaka/pdfgen/PdfGeneratorTest.kt b/service/src/integrationTest/kotlin/fi/espoo/evaka/pdfgen/PdfGeneratorTest.kt index 7190068199e..58fedda1f4e 100755 --- a/service/src/integrationTest/kotlin/fi/espoo/evaka/pdfgen/PdfGeneratorTest.kt +++ b/service/src/integrationTest/kotlin/fi/espoo/evaka/pdfgen/PdfGeneratorTest.kt @@ -50,12 +50,12 @@ import fi.espoo.evaka.shared.template.ITemplateProvider import fi.espoo.evaka.test.validPreschoolApplication import fi.espoo.evaka.testAdult_1 import fi.espoo.evaka.testChild_1 +import io.github.oshai.kotlinlogging.KotlinLogging import java.io.File import java.io.FileOutputStream import java.time.LocalDate import java.util.UUID import kotlin.test.assertNotNull -import mu.KotlinLogging import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest diff --git a/service/src/main/kotlin/fi/espoo/evaka/Audit.kt b/service/src/main/kotlin/fi/espoo/evaka/Audit.kt index 2c9fe4d54a6..6fce0406093 100755 --- a/service/src/main/kotlin/fi/espoo/evaka/Audit.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/Audit.kt @@ -6,8 +6,8 @@ package fi.espoo.evaka import fi.espoo.evaka.shared.Id import fi.espoo.voltti.logging.loggers.audit +import io.github.oshai.kotlinlogging.KotlinLogging import java.util.UUID -import mu.KotlinLogging sealed interface AuditId { val value: Any diff --git a/service/src/main/kotlin/fi/espoo/evaka/EvakaEnv.kt b/service/src/main/kotlin/fi/espoo/evaka/EvakaEnv.kt index 62abdc1659f..858390fc65e 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/EvakaEnv.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/EvakaEnv.kt @@ -9,13 +9,13 @@ import fi.espoo.evaka.daycare.domain.Language import fi.espoo.evaka.shared.domain.Rectangle import fi.espoo.evaka.shared.job.JobSchedule import fi.espoo.evaka.shared.job.ScheduledJobSettings +import io.github.oshai.kotlinlogging.KotlinLogging import java.net.URI import java.security.KeyStore import java.time.Duration import java.time.LocalDate import java.time.YearMonth import java.util.Locale -import mu.KotlinLogging import org.springframework.core.env.Environment import org.springframework.core.io.UrlResource diff --git a/service/src/main/kotlin/fi/espoo/evaka/absence/AbsencePushNotifications.kt b/service/src/main/kotlin/fi/espoo/evaka/absence/AbsencePushNotifications.kt index 4a1bb669771..7c40a49d27c 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/absence/AbsencePushNotifications.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/absence/AbsencePushNotifications.kt @@ -22,9 +22,9 @@ import fi.espoo.evaka.webpush.WebPushNotification import fi.espoo.evaka.webpush.WebPushPayload import fi.espoo.evaka.webpush.deletePushSubscription import fi.espoo.voltti.logging.loggers.info +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.Duration import java.time.LocalDate -import mu.KotlinLogging import org.springframework.stereotype.Service @Service @@ -168,9 +168,9 @@ AND notification.device = ${bind(device)} ), ) } catch (e: WebPush.SubscriptionExpired) { - logger.warn( + logger.warn { "Subscription expired for device $device (HTTP status ${e.status}) -> deleting" - ) + } dbc.transaction { it.deletePushSubscription(device) } } } diff --git a/service/src/main/kotlin/fi/espoo/evaka/application/ApplicationQueries.kt b/service/src/main/kotlin/fi/espoo/evaka/application/ApplicationQueries.kt index 80a1cb87c67..a7a52852b51 100755 --- a/service/src/main/kotlin/fi/espoo/evaka/application/ApplicationQueries.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/application/ApplicationQueries.kt @@ -28,9 +28,9 @@ import fi.espoo.evaka.shared.domain.HelsinkiDateTime import fi.espoo.evaka.shared.security.actionrule.AccessControlFilter import fi.espoo.evaka.shared.security.actionrule.forTable import fi.espoo.evaka.user.EvakaUser +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate import java.util.UUID -import mu.KotlinLogging private val logger = KotlinLogging.logger {} @@ -1240,9 +1240,9 @@ fun Database.Transaction.removeOldDrafts(clock: EvakaClock) { .toList() if (applicationIds.isNotEmpty()) { - logger.info( + logger.info { "Cleaning up ${applicationIds.size} draft applications older than $thresholdDays days" - ) + } execute { sql( diff --git a/service/src/main/kotlin/fi/espoo/evaka/application/ApplicationReceivedEmailService.kt b/service/src/main/kotlin/fi/espoo/evaka/application/ApplicationReceivedEmailService.kt index 75be8a448ae..835f5462567 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/application/ApplicationReceivedEmailService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/application/ApplicationReceivedEmailService.kt @@ -12,7 +12,7 @@ import fi.espoo.evaka.emailclient.IEmailMessageProvider import fi.espoo.evaka.pis.EmailMessageType import fi.espoo.evaka.shared.PersonId import fi.espoo.evaka.shared.db.Database -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.springframework.stereotype.Service private val logger = KotlinLogging.logger {} diff --git a/service/src/main/kotlin/fi/espoo/evaka/application/DecisionMessageProcessor.kt b/service/src/main/kotlin/fi/espoo/evaka/application/DecisionMessageProcessor.kt index 4df8b6f8145..96756a40e69 100755 --- a/service/src/main/kotlin/fi/espoo/evaka/application/DecisionMessageProcessor.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/application/DecisionMessageProcessor.kt @@ -9,7 +9,7 @@ import fi.espoo.evaka.shared.async.AsyncJob import fi.espoo.evaka.shared.async.AsyncJobRunner import fi.espoo.evaka.shared.db.Database import fi.espoo.evaka.shared.domain.EvakaClock -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.springframework.stereotype.Component private val logger = KotlinLogging.logger {} diff --git a/service/src/main/kotlin/fi/espoo/evaka/application/PendingDecisionEmailService.kt b/service/src/main/kotlin/fi/espoo/evaka/application/PendingDecisionEmailService.kt index e3e2f513036..93d2c604dfe 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/application/PendingDecisionEmailService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/application/PendingDecisionEmailService.kt @@ -19,8 +19,8 @@ import fi.espoo.evaka.shared.async.AsyncJobType import fi.espoo.evaka.shared.async.removeUnclaimedJobs import fi.espoo.evaka.shared.db.Database import fi.espoo.evaka.shared.domain.EvakaClock +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.Duration -import mu.KotlinLogging import org.springframework.stereotype.Service private val logger = KotlinLogging.logger {} @@ -41,7 +41,7 @@ class PendingDecisionEmailService( clock: EvakaClock, msg: AsyncJob.SendPendingDecisionEmail, ) { - logger.info("Sending pending decision reminder email to guardian ${msg.guardianId}") + logger.info { "Sending pending decision reminder email to guardian ${msg.guardianId}" } sendPendingDecisionEmail(db, clock, msg) } @@ -80,15 +80,15 @@ GROUP BY application.guardian_id tx.getPersonById(pendingDecision.guardianId).let { guardian -> when { guardian == null -> { - logger.warn( + logger.warn { "Could not send pending decision email to guardian ${pendingDecision.guardianId}: guardian not found" - ) + } count } guardian.email.isNullOrBlank() -> { - logger.warn( + logger.warn { "Could not send pending decision email to guardian ${guardian.id}: invalid email" - ) + } count } else -> { @@ -112,9 +112,9 @@ GROUP BY application.guardian_id } } - logger.info( + logger.info { "PendingDecisionEmailService: Scheduled sending $createdJobCount pending decision emails" - ) + } createdJobCount } @@ -126,7 +126,7 @@ GROUP BY application.guardian_id clock: EvakaClock, pendingDecision: AsyncJob.SendPendingDecisionEmail, ) { - logger.info("Sending pending decision email to guardian ${pendingDecision.guardianId}") + logger.info { "Sending pending decision email to guardian ${pendingDecision.guardianId}" } val lang = getLanguage(pendingDecision.language) Email.create( diff --git a/service/src/main/kotlin/fi/espoo/evaka/application/SendApplicationReceivedEmailAsyncJobs.kt b/service/src/main/kotlin/fi/espoo/evaka/application/SendApplicationReceivedEmailAsyncJobs.kt index 85314b343f3..ca6fb5e6dab 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/application/SendApplicationReceivedEmailAsyncJobs.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/application/SendApplicationReceivedEmailAsyncJobs.kt @@ -7,7 +7,7 @@ package fi.espoo.evaka.application import fi.espoo.evaka.shared.async.AsyncJob import fi.espoo.evaka.shared.async.AsyncJobRunner import fi.espoo.evaka.shared.db.Database -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.springframework.stereotype.Component private val logger = KotlinLogging.logger {} diff --git a/service/src/main/kotlin/fi/espoo/evaka/assistanceneed/decision/AssistanceNeedDecisionService.kt b/service/src/main/kotlin/fi/espoo/evaka/assistanceneed/decision/AssistanceNeedDecisionService.kt index f77a4704f23..dd1229d70ed 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/assistanceneed/decision/AssistanceNeedDecisionService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/assistanceneed/decision/AssistanceNeedDecisionService.kt @@ -37,8 +37,8 @@ import fi.espoo.evaka.shared.domain.NotFound import fi.espoo.evaka.shared.domain.OfficialLanguage import fi.espoo.evaka.shared.message.IMessageProvider import fi.espoo.evaka.shared.template.ITemplateProvider +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate -import mu.KotlinLogging import org.springframework.http.ResponseEntity import org.springframework.stereotype.Component import org.thymeleaf.context.Context diff --git a/service/src/main/kotlin/fi/espoo/evaka/assistanceneed/preschooldecision/AssistanceNeedPreschoolDecisionService.kt b/service/src/main/kotlin/fi/espoo/evaka/assistanceneed/preschooldecision/AssistanceNeedPreschoolDecisionService.kt index 0ee814e4d9d..5501761b006 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/assistanceneed/preschooldecision/AssistanceNeedPreschoolDecisionService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/assistanceneed/preschooldecision/AssistanceNeedPreschoolDecisionService.kt @@ -33,8 +33,8 @@ import fi.espoo.evaka.shared.domain.NotFound import fi.espoo.evaka.shared.domain.OfficialLanguage import fi.espoo.evaka.shared.message.IMessageProvider import fi.espoo.evaka.shared.template.ITemplateProvider +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate -import mu.KotlinLogging import org.springframework.http.ResponseEntity import org.springframework.stereotype.Component import org.thymeleaf.context.Context diff --git a/service/src/main/kotlin/fi/espoo/evaka/attachment/AttachmentService.kt b/service/src/main/kotlin/fi/espoo/evaka/attachment/AttachmentService.kt index 71f7c28adce..d5968c449f7 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/attachment/AttachmentService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/attachment/AttachmentService.kt @@ -12,7 +12,7 @@ import fi.espoo.evaka.shared.async.AsyncJobRunner import fi.espoo.evaka.shared.auth.AuthenticatedUser import fi.espoo.evaka.shared.db.Database import fi.espoo.evaka.shared.domain.EvakaClock -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.springframework.stereotype.Service @Service @@ -61,7 +61,7 @@ class AttachmentService( * and/or the database. */ fun deleteAttachment(dbc: Database.Connection, id: AttachmentId) { - logger.info("Deleting attachment $id") + logger.info { "Deleting attachment $id" } dbc.close() // avoid hogging the connection while we access S3 // AWS S3 client seems to be idempotent, so deleting a non-existing file doesn't throw an // error @@ -83,7 +83,7 @@ WHERE id = ${bind(id)} fun scheduleOrphanAttachmentDeletion(tx: Database.Transaction, clock: EvakaClock) { val ids = tx.getOrphanAttachments(olderThan = clock.now().minusDays(1)) - logger.info("Scheduling deletion for ${ids.size} orphan attachments") + logger.info { "Scheduling deletion for ${ids.size} orphan attachments" } asyncJobRunner.plan(tx, ids.map { AsyncJob.DeleteAttachment(it) }, runAt = clock.now()) } } diff --git a/service/src/main/kotlin/fi/espoo/evaka/calendarevent/CalendarEventNotificationService.kt b/service/src/main/kotlin/fi/espoo/evaka/calendarevent/CalendarEventNotificationService.kt index 7fa3d263164..2f3ea6b8280 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/calendarevent/CalendarEventNotificationService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/calendarevent/CalendarEventNotificationService.kt @@ -21,7 +21,7 @@ import fi.espoo.evaka.shared.db.Database import fi.espoo.evaka.shared.domain.EvakaClock import fi.espoo.evaka.shared.domain.HelsinkiDateTime import fi.espoo.evaka.shared.domain.NotFound -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.springframework.stereotype.Service private val logger = KotlinLogging.logger {} @@ -47,7 +47,7 @@ class CalendarEventNotificationService( val recipientEventTimes = tx.getRecipientsForEventTimeRemindersAt(now.plusDays(2).toLocalDate()) - logger.info("Scheduling ${recipientEventTimes.size} discussion time reminder mails") + logger.info { "Scheduling ${recipientEventTimes.size} discussion time reminder mails" } asyncJobRunner.plan( tx, payloads = @@ -68,9 +68,9 @@ class CalendarEventNotificationService( val parentsWithDiscussionSurveys = tx.getParentsWithNewDiscussionSurveysAfter(now.minusHours(24)) - logger.info( + logger.info { "Scheduling survey creation digests for ${parentsWithDiscussionSurveys.size} recipients" - ) + } asyncJobRunner.plan( tx, payloads = diff --git a/service/src/main/kotlin/fi/espoo/evaka/calendarevent/CalendarEventPushNotifications.kt b/service/src/main/kotlin/fi/espoo/evaka/calendarevent/CalendarEventPushNotifications.kt index 438d115a834..91faab9de07 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/calendarevent/CalendarEventPushNotifications.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/calendarevent/CalendarEventPushNotifications.kt @@ -24,9 +24,9 @@ import fi.espoo.evaka.webpush.WebPushNotification import fi.espoo.evaka.webpush.WebPushPayload import fi.espoo.evaka.webpush.deletePushSubscription import fi.espoo.voltti.logging.loggers.info +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.Duration import java.time.format.DateTimeFormatter -import mu.KotlinLogging import org.springframework.stereotype.Service @Service @@ -130,18 +130,24 @@ AND 'CALENDAR_EVENT_RESERVATION' = ANY(md.push_notification_categories) listOf( WebPushPayload.NotificationV1( title = - "${notification.groupName}: Huoltaja ${when (job.type) { - CalendarEventReservationNotificationType.RESERVED -> "varannut" - CalendarEventReservationNotificationType.CANCELLED -> "perunut" - }} keskusteluajan ${job.date.format(dateFormat)} klo ${job.startTime.format(timeFormat)} - ${job.endTime.format(timeFormat)}" + "${notification.groupName}: Huoltaja ${ + when (job.type) { + CalendarEventReservationNotificationType.RESERVED -> "varannut" + CalendarEventReservationNotificationType.CANCELLED -> "perunut" + } + } keskusteluajan ${job.date.format(dateFormat)} klo ${ + job.startTime.format( + timeFormat + ) + } - ${job.endTime.format(timeFormat)}" ) ), ), ) } catch (e: WebPush.SubscriptionExpired) { - logger.warn( + logger.warn { "Subscription expired for device $device (HTTP status ${e.status}) -> deleting" - ) + } dbc.transaction { it.deletePushSubscription(device) } } } diff --git a/service/src/main/kotlin/fi/espoo/evaka/daycare/controllers/TermsController.kt b/service/src/main/kotlin/fi/espoo/evaka/daycare/controllers/TermsController.kt index 02caa0a514a..acfd6d574f3 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/daycare/controllers/TermsController.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/daycare/controllers/TermsController.kt @@ -29,7 +29,7 @@ import fi.espoo.evaka.shared.domain.FiniteDateRange import fi.espoo.evaka.shared.domain.NotFound import fi.espoo.evaka.shared.security.AccessControl import fi.espoo.evaka.shared.security.Action -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.springframework.web.bind.annotation.DeleteMapping import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PathVariable diff --git a/service/src/main/kotlin/fi/espoo/evaka/decision/DecisionSendAddress.kt b/service/src/main/kotlin/fi/espoo/evaka/decision/DecisionSendAddress.kt index 7f8166b323f..2bdc1f70ae3 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/decision/DecisionSendAddress.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/decision/DecisionSendAddress.kt @@ -24,9 +24,9 @@ fun getSendAddress( lang: OfficialLanguage, ): DecisionSendAddress { val logMissingAddress = { - logger.warn( + logger.warn { "Cannot deliver daycare decision to guardian ${guardian.id} with incomplete address. Using default decision address." - ) + } } return when { guardian.restrictedDetailsEnabled -> messageProvider.getDefaultDecisionAddress(lang) diff --git a/service/src/main/kotlin/fi/espoo/evaka/decision/DecisionService.kt b/service/src/main/kotlin/fi/espoo/evaka/decision/DecisionService.kt index dfd5a7d4c09..f877d2e6970 100755 --- a/service/src/main/kotlin/fi/espoo/evaka/decision/DecisionService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/decision/DecisionService.kt @@ -43,7 +43,7 @@ import fi.espoo.evaka.shared.domain.NotFound import fi.espoo.evaka.shared.domain.OfficialLanguage import fi.espoo.evaka.shared.message.IMessageProvider import fi.espoo.evaka.shared.template.ITemplateProvider -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.springframework.http.ResponseEntity import org.springframework.stereotype.Service import org.thymeleaf.context.Context @@ -186,9 +186,9 @@ class DecisionService( if (currentGuardians.contains(applicationGuardian.id)) { deliverDecisionToGuardian(tx, clock, decision, applicationGuardian, documentLocation) } else { - logger.warn( + logger.warn { "Skipping sending decision $decisionId to application guardian ${applicationGuardian.id} - not a current guardian or foster parent" - ) + } } if ( @@ -210,9 +210,9 @@ class DecisionService( documentLocation, ) } else { - logger.warn( + logger.warn { "Skipping sending decision $decisionId to application other guardian $guardianId - not a current guardian or foster parent" - ) + } } } } @@ -293,9 +293,9 @@ class DecisionService( ) ?.also { emailClient.send(it) } } else { - logger.warn( + logger.warn { "Skipping sending decision for application $applicationId guardian - not a current guardian or foster parent" - ) + } } } diff --git a/service/src/main/kotlin/fi/espoo/evaka/document/childdocument/ChildDocumentService.kt b/service/src/main/kotlin/fi/espoo/evaka/document/childdocument/ChildDocumentService.kt index 639568e2fde..ac898b12bbc 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/document/childdocument/ChildDocumentService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/document/childdocument/ChildDocumentService.kt @@ -23,8 +23,8 @@ import fi.espoo.evaka.shared.domain.EvakaClock import fi.espoo.evaka.shared.domain.FiniteDateRange import fi.espoo.evaka.shared.domain.HelsinkiDateTime import fi.espoo.evaka.shared.domain.NotFound +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate -import mu.KotlinLogging import org.springframework.http.ResponseEntity import org.springframework.stereotype.Service @@ -86,7 +86,14 @@ class ChildDocumentService( SELECT cd.id FROM child_document cd JOIN document_template dt on dt.id = cd.template_id - WHERE dt.validity << ${bind(FiniteDateRange(now.toLocalDate(), now.toLocalDate()))} AND cd.status <> 'COMPLETED' + WHERE dt.validity << ${ + bind( + FiniteDateRange( + now.toLocalDate(), + now.toLocalDate(), + ) + ) + } AND cd.status <> 'COMPLETED' """ .trimIndent() ) @@ -197,9 +204,9 @@ WHERE person.email IS NOT NULL AND person.email != '' clock: EvakaClock, msg: AsyncJob.SendChildDocumentNotificationEmail, ) { - logger.info( + logger.info { "Sending child document notification email for document ${msg.documentId} to person ${msg.recipientId}" - ) + } Email.create( dbc = db, personId = msg.recipientId, diff --git a/service/src/main/kotlin/fi/espoo/evaka/dvv/DvvModificationsBatchRefreshService.kt b/service/src/main/kotlin/fi/espoo/evaka/dvv/DvvModificationsBatchRefreshService.kt index ed5ba4da85b..cb9634eceeb 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/dvv/DvvModificationsBatchRefreshService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/dvv/DvvModificationsBatchRefreshService.kt @@ -10,8 +10,8 @@ import fi.espoo.evaka.shared.async.AsyncJobType import fi.espoo.evaka.shared.async.removeUnclaimedJobs import fi.espoo.evaka.shared.db.Database import fi.espoo.evaka.shared.domain.EvakaClock +import io.github.oshai.kotlinlogging.KotlinLogging import java.util.UUID -import mu.KotlinLogging import org.springframework.stereotype.Service private val logger = KotlinLogging.logger {} @@ -30,11 +30,11 @@ class DvvModificationsBatchRefreshService( clock: EvakaClock, msg: AsyncJob.DvvModificationsRefresh, ) { - logger.info("DvvModificationsRefresh: starting to process ${msg.ssns.size} ssns") + logger.info { "DvvModificationsRefresh: starting to process ${msg.ssns.size} ssns" } val modificationCount = dvvModificationsService.updatePersonsFromDvv(db, clock, msg.ssns) - logger.info( + logger.info { "DvvModificationsRefresh: finished processing $modificationCount DVV person modifications for ${msg.ssns.size} ssns" - ) + } } fun scheduleBatch(db: Database.Connection, clock: EvakaClock): Int { diff --git a/service/src/main/kotlin/fi/espoo/evaka/dvv/DvvModificationsService.kt b/service/src/main/kotlin/fi/espoo/evaka/dvv/DvvModificationsService.kt index 80c672c33e5..e2383184ac0 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/dvv/DvvModificationsService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/dvv/DvvModificationsService.kt @@ -19,8 +19,8 @@ import fi.espoo.evaka.shared.async.AsyncJobRunner import fi.espoo.evaka.shared.db.Database import fi.espoo.evaka.shared.domain.DateRange import fi.espoo.evaka.shared.domain.EvakaClock +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate -import mu.KotlinLogging import org.springframework.stereotype.Service private val logger = KotlinLogging.logger {} @@ -48,46 +48,53 @@ class DvvModificationsService( personModifications.henkilotunnus, infoGroup, ) + is RestrictedInfoDvvInfoGroup -> handleRestrictedInfo( db, personModifications.henkilotunnus, infoGroup, ) + is SsnDvvInfoGroup -> handleSsnDvvInfoGroup( db, personModifications.henkilotunnus, infoGroup, ) + is CaretakerLimitedDvvInfoGroup -> { if (infoGroup.huoltaja.henkilotunnus != null) { ssnsToUpdateFromVtj.add( infoGroup.huoltaja.henkilotunnus ) } else { - logger.info( + logger.info { "Dvv modification ignored for caretaker: ssn is null" - ) + } } } + is DefaultDvvInfoGroup -> ssnsToUpdateFromVtj.add(personModifications.henkilotunnus) + else -> { - logger.error( - "Refreshing person from VTJ for an unknown DVV modification type: ${infoGroup.tietoryhma} (all modification in this group: ${personModifications.tietoryhmat.map { it.tietoryhma }.joinToString(", ")})" - ) + logger.error { + "Refreshing person from VTJ for an unknown DVV modification type: ${infoGroup.tietoryhma} (all modification in this group: ${ + personModifications.tietoryhmat.map { it.tietoryhma }.joinToString(", ") + })" + } ssnsToUpdateFromVtj.add(personModifications.henkilotunnus) } } } catch (e: Throwable) { logger.error(e) { "Could not process dvv modification for ${ - personModifications.henkilotunnus.substring( - 0, - 6, - ) - }: ${e.message}" + personModifications.henkilotunnus.substring( + 0, + 6, + ) + }: ${e.message}" } throw e } @@ -95,9 +102,9 @@ class DvvModificationsService( } val personIds = db.read { it.getPersonIdsBySsns(ssnsToUpdateFromVtj.toList()) } - logger.info( + logger.info { "Dvv modifications: updating ${ssnsToUpdateFromVtj.size} persons from VTJ, of which existing persons are: $personIds" - ) + } db.transaction { tx -> asyncJobRunner.plan( @@ -135,7 +142,7 @@ class DvvModificationsService( db.transaction { tx -> tx.getPersonBySSN(ssn)?.let { person -> val dateOfDeath = deathDvvInfoGroup.kuolinpv.asLocalDate() - logger.info("Dvv modification for ${person.id}: marking dead since $dateOfDeath") + logger.info { "Dvv modification for ${person.id}: marking dead since $dateOfDeath" } tx.updatePersonFromVtj(person.copy(dateOfDeath = dateOfDeath)) endFamilyRelations(tx, person.id, dateOfDeath, clock) @@ -217,9 +224,9 @@ class DvvModificationsService( ) = db.transaction { tx -> tx.getPersonBySSN(ssn)?.let { - logger.info( + logger.info { "Dvv modification for ${it.id}: restricted ${restrictedInfoDvvInfoGroup.turvakieltoAktiivinen}" - ) + } tx.updatePersonFromVtj( it.copy( restrictedDetailsEnabled = restrictedInfoDvvInfoGroup.turvakieltoAktiivinen, @@ -249,12 +256,12 @@ class DvvModificationsService( ) = db.transaction { tx -> tx.getPersonBySSN(ssn)?.let { - logger.info("Dvv modification for ${it.id}: ssn change") + logger.info { "Dvv modification for ${it.id}: ssn change" } if (!ssnDvvInfoGroup.aktiivinenHenkilotunnus.isNullOrEmpty()) { tx.addSSNToPerson(it.id, ssnDvvInfoGroup.aktiivinenHenkilotunnus) } else { - logger.error("Dvv modification for ${it.id}: ssn is set to null or empty") + logger.error { "Dvv modification for ${it.id}: ssn is set to null or empty" } } } } @@ -275,9 +282,9 @@ class DvvModificationsService( token: String, alreadyFoundDvvModifications: List, ): DvvModificationsWithToken { - logger.debug( + logger.debug { "Fetching dvv modifications with $token, found modifications so far: ${alreadyFoundDvvModifications.size}" - ) + } return dvvModificationsServiceClient.getModifications(token, ssns).let { dvvModificationsResponse -> val combinedModifications = diff --git a/service/src/main/kotlin/fi/espoo/evaka/dvv/DvvModificationsServiceClient.kt b/service/src/main/kotlin/fi/espoo/evaka/dvv/DvvModificationsServiceClient.kt index 6e0e1abc181..6abeb305ce8 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/dvv/DvvModificationsServiceClient.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/dvv/DvvModificationsServiceClient.kt @@ -16,12 +16,12 @@ import fi.espoo.evaka.DvvModificationsEnv import fi.espoo.evaka.KeystoreEnv import fi.espoo.evaka.VtjXroadEnv import fi.espoo.evaka.shared.trustAllCerts +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate import javax.net.ssl.HostnameVerifier import javax.net.ssl.KeyManagerFactory import javax.net.ssl.SSLContext import javax.net.ssl.TrustManagerFactory -import mu.KotlinLogging import org.springframework.stereotype.Service private val logger = KotlinLogging.logger {} diff --git a/service/src/main/kotlin/fi/espoo/evaka/emailclient/EmailClient.kt b/service/src/main/kotlin/fi/espoo/evaka/emailclient/EmailClient.kt index dbf2d680709..d59cd39e0b5 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/emailclient/EmailClient.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/emailclient/EmailClient.kt @@ -9,7 +9,7 @@ import fi.espoo.evaka.pis.getEmployee import fi.espoo.evaka.shared.EmployeeId import fi.espoo.evaka.shared.PersonId import fi.espoo.evaka.shared.db.Database -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging private val EMAIL_PATTERN = "^([\\w.%+-]+)@([\\w-]+\\.)+([\\w]{2,})\$".toRegex() @@ -35,14 +35,16 @@ private constructor( dbc.read { tx -> tx.getEmailAddressAndDisabledTypes(personId) } if (toAddress == null) { - logger.warn("Will not send email due to missing email address: (traceId: $traceId)") + logger.warn { + "Will not send email due to missing email address: (traceId: $traceId)" + } return null } if (!toAddress.matches(EMAIL_PATTERN)) { - logger.warn( + logger.warn { "Will not send email due to invalid toAddress \"$toAddress\": (traceId: $traceId)" - ) + } return null } @@ -66,14 +68,16 @@ private constructor( val employee = dbc.read { it.getEmployee(employeeId) } ?: return null if (employee.email == null) { - logger.warn("Will not send email due to missing email address: (traceId: $traceId)") + logger.warn { + "Will not send email due to missing email address: (traceId: $traceId)" + } return null } if (!employee.email.matches(EMAIL_PATTERN)) { - logger.warn( + logger.warn { "Will not send email due to invalid toAddress \"${employee.email}\": (traceId: $traceId)" - ) + } return null } diff --git a/service/src/main/kotlin/fi/espoo/evaka/emailclient/MockEmailClient.kt b/service/src/main/kotlin/fi/espoo/evaka/emailclient/MockEmailClient.kt index 30264b890b6..fd0bdb2b7ae 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/emailclient/MockEmailClient.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/emailclient/MockEmailClient.kt @@ -4,10 +4,10 @@ package fi.espoo.evaka.emailclient +import io.github.oshai.kotlinlogging.KotlinLogging import java.util.concurrent.locks.ReentrantReadWriteLock import kotlin.concurrent.read import kotlin.concurrent.write -import mu.KotlinLogging private val logger = KotlinLogging.logger {} diff --git a/service/src/main/kotlin/fi/espoo/evaka/emailclient/SESEmailClient.kt b/service/src/main/kotlin/fi/espoo/evaka/emailclient/SESEmailClient.kt index b50262dd223..d4c27df299a 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/emailclient/SESEmailClient.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/emailclient/SESEmailClient.kt @@ -4,7 +4,7 @@ package fi.espoo.evaka.emailclient -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.unbescape.html.HtmlEscape import software.amazon.awssdk.services.ses.SesClient import software.amazon.awssdk.services.ses.model.AccountSendingPausedException diff --git a/service/src/main/kotlin/fi/espoo/evaka/espoo/EspooScheduledJobs.kt b/service/src/main/kotlin/fi/espoo/evaka/espoo/EspooScheduledJobs.kt index 9c05e001d55..56ad7c5029b 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/espoo/EspooScheduledJobs.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/espoo/EspooScheduledJobs.kt @@ -16,8 +16,8 @@ import fi.espoo.evaka.shared.domain.EvakaClock import fi.espoo.evaka.shared.job.JobSchedule import fi.espoo.evaka.shared.job.ScheduledJobDefinition import fi.espoo.evaka.shared.job.ScheduledJobSettings +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalTime -import mu.KotlinLogging enum class EspooScheduledJob( val fn: (EspooScheduledJobs, Database.Connection, EvakaClock) -> Unit, @@ -46,13 +46,13 @@ class EspooScheduledJobs( fun sendPatuReport(db: Database.Connection, clock: EvakaClock) { val fourtyDaysAgo = clock.today().minusDays(40) - logger.info("Sending patu report for $fourtyDaysAgo") + logger.info { "Sending patu report for $fourtyDaysAgo" } patuReportingService.sendPatuReport(db, DateRange(fourtyDaysAgo, fourtyDaysAgo)) } fun planBiJobs(db: Database.Connection, clock: EvakaClock) { val tables = EspooBiTable.values() - logger.info("Planning BI jobs for ${tables.size} tables") + logger.info { "Planning BI jobs for ${tables.size} tables" } db.transaction { tx -> tx.removeUnclaimedJobs(setOf(AsyncJobType(EspooAsyncJob.SendBiTable::class))) espooAsyncJobRunner.plan( diff --git a/service/src/main/kotlin/fi/espoo/evaka/espoo/bi/EspooBiHttpClient.kt b/service/src/main/kotlin/fi/espoo/evaka/espoo/bi/EspooBiHttpClient.kt index 722ce71358f..345756d3789 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/espoo/bi/EspooBiHttpClient.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/espoo/bi/EspooBiHttpClient.kt @@ -9,8 +9,8 @@ import com.github.kittinunf.fuel.core.extensions.authentication import com.github.kittinunf.fuel.core.requests.DefaultBody import fi.espoo.evaka.EspooBiEnv import fi.espoo.voltti.logging.loggers.error +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.Duration -import mu.KotlinLogging class EspooBiHttpClient(private val env: EspooBiEnv) : EspooBiClient { private val fuel = FuelManager() @@ -18,7 +18,7 @@ class EspooBiHttpClient(private val env: EspooBiEnv) : EspooBiClient { private val readTimeout = Duration.ofMinutes(5) override fun sendBiCsvFile(fileName: String, stream: EspooBiJob.CsvInputStream) { - logger.info("Sending BI CSV file $fileName") + logger.info { "Sending BI CSV file $fileName" } val (_, _, result) = fuel .put("${env.url}/report", listOf("filename" to fileName)) @@ -29,7 +29,11 @@ class EspooBiHttpClient(private val env: EspooBiEnv) : EspooBiClient { .body(DefaultBody({ stream })) .responseString() result.fold( - { logger.info("Sent BI CSV file $fileName successfully (${stream.totalBytes} bytes)") }, + { + logger.info { + "Sent BI CSV file $fileName successfully (${stream.totalBytes} bytes)" + } + }, { error -> val meta = mapOf("errorMessage" to error.errorData.decodeToString()) logger.error(error, meta) { diff --git a/service/src/main/kotlin/fi/espoo/evaka/espoo/bi/MockEspooBiClient.kt b/service/src/main/kotlin/fi/espoo/evaka/espoo/bi/MockEspooBiClient.kt index 4d482ae83c4..62768a9770b 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/espoo/bi/MockEspooBiClient.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/espoo/bi/MockEspooBiClient.kt @@ -5,7 +5,7 @@ package fi.espoo.evaka.espoo.bi import com.google.common.io.ByteStreams -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging class MockEspooBiClient : EspooBiClient { private val logger = KotlinLogging.logger {} diff --git a/service/src/main/kotlin/fi/espoo/evaka/invoicing/data/ExceptionHandling.kt b/service/src/main/kotlin/fi/espoo/evaka/invoicing/data/ExceptionHandling.kt index 5dd6d476dc7..adc56db4edd 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/invoicing/data/ExceptionHandling.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/invoicing/data/ExceptionHandling.kt @@ -6,7 +6,7 @@ package fi.espoo.evaka.invoicing.data import fi.espoo.evaka.shared.domain.BadRequest import fi.espoo.evaka.shared.domain.Conflict -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.postgresql.util.PSQLException // PostgreSQL error codes @@ -26,12 +26,14 @@ fun handlingExceptions(fn: () -> T): T { when (this.sqlState) { dataException, checkViolation -> throw BadRequest("Invalid data", cause = e) + exclusionViolation -> throw Conflict("Exclusion constraint violation in database", cause = e) + else -> { - logger.warn( + logger.warn { "Unmapped PSQLException sqlState error code ${this.sqlState}" - ) + } throw this } } diff --git a/service/src/main/kotlin/fi/espoo/evaka/invoicing/domain/Payments.kt b/service/src/main/kotlin/fi/espoo/evaka/invoicing/domain/Payments.kt index 6341a734581..bd9025c32ea 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/invoicing/domain/Payments.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/invoicing/domain/Payments.kt @@ -20,9 +20,9 @@ import fi.espoo.evaka.shared.domain.BadRequest import fi.espoo.evaka.shared.domain.DateRange import fi.espoo.evaka.shared.domain.HelsinkiDateTime import fi.espoo.evaka.shared.security.actionrule.AccessControlFilter +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate import java.time.temporal.TemporalAdjusters -import mu.KotlinLogging import org.jdbi.v3.core.mapper.Nested val logger = KotlinLogging.logger {} @@ -37,9 +37,9 @@ interface PaymentIntegrationClient { class MockClient(private val jsonMapper: JsonMapper) : PaymentIntegrationClient { override fun send(payments: List, tx: Database.Read): SendResult { - logger.info( + logger.info { "Mock payment integration client got payments ${jsonMapper.writeValueAsString(payments)}" - ) + } return SendResult(succeeded = payments) } } diff --git a/service/src/main/kotlin/fi/espoo/evaka/invoicing/integration/EspooInvoiceIntegrationClient.kt b/service/src/main/kotlin/fi/espoo/evaka/invoicing/integration/EspooInvoiceIntegrationClient.kt index b6dd7182542..1aeea6ebbc7 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/invoicing/integration/EspooInvoiceIntegrationClient.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/invoicing/integration/EspooInvoiceIntegrationClient.kt @@ -16,8 +16,8 @@ import fi.espoo.evaka.invoicing.service.ProductKey import fi.espoo.evaka.shared.domain.europeHelsinki import fi.espoo.voltti.logging.loggers.error import fi.espoo.voltti.logging.loggers.info +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate -import mu.KotlinLogging private val logger = KotlinLogging.logger {} @@ -39,9 +39,9 @@ class EspooInvoiceIntegrationClient( sendBatch(invoices, agreementType) } else { val areaIds = invoices.asSequence().map { it.areaId }.distinct().sorted() - logger.error( + logger.error { "Failed to send ${invoices.size} invoices due to missing areaCode in the following areas: ${areaIds.joinToString()}" - ) + } false } success to invoices @@ -65,7 +65,9 @@ class EspooInvoiceIntegrationClient( ) { "Sending invoice batch to integration" } - logger.debug("Sending invoice batch ${batch.batchNumber} to integration, payload: $payload") + logger.debug { + "Sending invoice batch ${batch.batchNumber} to integration, payload: $payload" + } val (_, _, result) = fuel .post("${env.url}/invoice-batches") @@ -171,9 +173,9 @@ class EspooInvoiceIntegrationClient( // some part of address does not fit string length limitations if (streetAddress.length > 36 || postalCode.length > 5 || postOffice.length > 40) { - logger.warn( + logger.warn { "Invoice recipient address was non-empty, but some part of it was too long for invoice integration, streetAddress: '$streetAddress', postalCode: '$postalCode', postOffice: '$postOffice'" - ) + } return false } @@ -235,6 +237,7 @@ class EspooInvoiceIntegrationClient( invoiceAddress.second, invoiceAddress.third, ) -> invoiceAddress + addressIsValid(address.first, address.second, address.third) -> address else -> Triple(fallbackStreetAddress, fallbackPostalCode, fallbackPostOffice) } diff --git a/service/src/main/kotlin/fi/espoo/evaka/invoicing/integration/InvoiceIntegrationClient.kt b/service/src/main/kotlin/fi/espoo/evaka/invoicing/integration/InvoiceIntegrationClient.kt index a4d6b925a96..4a2d54b531c 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/invoicing/integration/InvoiceIntegrationClient.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/invoicing/integration/InvoiceIntegrationClient.kt @@ -6,7 +6,7 @@ package fi.espoo.evaka.invoicing.integration import com.fasterxml.jackson.databind.json.JsonMapper import fi.espoo.evaka.invoicing.domain.InvoiceDetailed -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging private val logger = KotlinLogging.logger {} @@ -21,9 +21,9 @@ interface InvoiceIntegrationClient { class MockClient(private val jsonMapper: JsonMapper) : InvoiceIntegrationClient { override fun send(invoices: List): SendResult { - logger.info( + logger.info { "Mock invoice integration client got invoices ${jsonMapper.writeValueAsString(invoices)}" - ) + } val (withSSN, withoutSSN) = invoices.partition { invoice -> invoice.headOfFamily.ssn != null } return SendResult(succeeded = withSSN, manuallySent = withoutSSN) diff --git a/service/src/main/kotlin/fi/espoo/evaka/invoicing/messaging/FeeDecisionGenerationJobProcessor.kt b/service/src/main/kotlin/fi/espoo/evaka/invoicing/messaging/FeeDecisionGenerationJobProcessor.kt index ef853678157..08ae7bf0e33 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/invoicing/messaging/FeeDecisionGenerationJobProcessor.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/invoicing/messaging/FeeDecisionGenerationJobProcessor.kt @@ -11,7 +11,7 @@ import fi.espoo.evaka.shared.async.AsyncJobRunner import fi.espoo.evaka.shared.db.Database import fi.espoo.evaka.shared.domain.DateRange import fi.espoo.evaka.shared.domain.EvakaClock -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.springframework.stereotype.Component private val logger = KotlinLogging.logger {} diff --git a/service/src/main/kotlin/fi/espoo/evaka/invoicing/messaging/InvoicingAsyncJobs.kt b/service/src/main/kotlin/fi/espoo/evaka/invoicing/messaging/InvoicingAsyncJobs.kt index fa87fded8c3..6c69a112468 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/invoicing/messaging/InvoicingAsyncJobs.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/invoicing/messaging/InvoicingAsyncJobs.kt @@ -10,7 +10,7 @@ import fi.espoo.evaka.shared.async.AsyncJob import fi.espoo.evaka.shared.async.AsyncJobRunner import fi.espoo.evaka.shared.db.Database import fi.espoo.evaka.shared.domain.EvakaClock -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.springframework.stereotype.Component private val logger = KotlinLogging.logger {} diff --git a/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/FeeDecisionService.kt b/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/FeeDecisionService.kt index 03511ebd844..b3816ba0288 100755 --- a/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/FeeDecisionService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/FeeDecisionService.kt @@ -66,8 +66,8 @@ import fi.espoo.evaka.shared.domain.NotFound import fi.espoo.evaka.shared.domain.OfficialLanguage import fi.espoo.evaka.shared.message.IMessageProvider import fi.espoo.voltti.logging.loggers.info +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate -import mu.KotlinLogging import org.springframework.http.ResponseEntity import org.springframework.stereotype.Component @@ -332,7 +332,7 @@ class FeeDecisionService( messageContent = messageProvider.getFeeDecisionContent(lang), ) - logger.info("Sending fee decision as suomi.fi message ${message.documentId}") + logger.info { "Sending fee decision as suomi.fi message ${message.documentId}" } asyncJobRunner.plan(tx, listOf(AsyncJob.SendMessage(message)), runAt = clock.now()) asyncJobRunner.plan( diff --git a/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/FinanceDecisionGenerator.kt b/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/FinanceDecisionGenerator.kt index bb14e2c0bef..a138fe5bd09 100755 --- a/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/FinanceDecisionGenerator.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/FinanceDecisionGenerator.kt @@ -15,8 +15,8 @@ import fi.espoo.evaka.shared.FeatureConfig import fi.espoo.evaka.shared.PersonId import fi.espoo.evaka.shared.db.Database import fi.espoo.evaka.shared.domain.DateRange +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate -import mu.KotlinLogging import org.springframework.stereotype.Component private val logger = KotlinLogging.logger {} diff --git a/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/InvoiceGenerator.kt b/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/InvoiceGenerator.kt index c9d790f5d0c..f8998f35791 100755 --- a/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/InvoiceGenerator.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/InvoiceGenerator.kt @@ -46,7 +46,7 @@ import kotlin.math.abs import org.jdbi.v3.core.mapper.Nested import org.springframework.stereotype.Component -private val logger = mu.KotlinLogging.logger {} +private val logger = io.github.oshai.kotlinlogging.KotlinLogging.logger {} @Component class InvoiceGenerator( @@ -126,7 +126,7 @@ class InvoiceGenerator( ) { val replacementInvoicesStart = env.replacementInvoicesStart if (replacementInvoicesStart == null) { - logger.info("Replacement invoices are not enabled") + logger.info { "Replacement invoices are not enabled" } return } @@ -143,7 +143,7 @@ class InvoiceGenerator( try { dbc.transaction { tx -> fn(tx, month) } } catch (e: Exception) { - logger.error("Failed to create replacement draft invoices for $month", e) + logger.error(e) { "Failed to create replacement draft invoices for $month" } } month = month.plusMonths(1) } diff --git a/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/NewCustomerIncomeNotification.kt b/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/NewCustomerIncomeNotification.kt index ec27ee240cd..5f9c9b87507 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/NewCustomerIncomeNotification.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/NewCustomerIncomeNotification.kt @@ -16,7 +16,7 @@ import fi.espoo.evaka.shared.async.AsyncJobType import fi.espoo.evaka.shared.async.removeUnclaimedJobs import fi.espoo.evaka.shared.db.Database import fi.espoo.evaka.shared.domain.EvakaClock -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.springframework.stereotype.Service private val logger = KotlinLogging.logger {} @@ -48,9 +48,9 @@ class NewCustomerIncomeNotification( runAt = clock.now(), ) - logger.info( + logger.info { "NewCustomerIncomeNotification scheduled notification emails: ${guardiansForNotification.size}" - ) + } return guardiansForNotification.size } @@ -82,9 +82,9 @@ class NewCustomerIncomeNotification( db.read { tx -> tx.newCustomerIdsForIncomeNotifications(clock.today(), msg.guardianId) } .contains(msg.guardianId) ) { - logger.info( + logger.info { "NewCustomerIncomeNotification: sending notification email to ${msg.guardianId}" - ) + } Email.create( dbc = db, @@ -104,9 +104,9 @@ class NewCustomerIncomeNotification( it.createIncomeNotification(msg.guardianId, IncomeNotificationType.NEW_CUSTOMER) } } else { - logger.info( + logger.info { "Skipping NewCustomerIncomeNotification: ${msg.guardianId} is no longer valid recipient" - ) + } } } } diff --git a/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/OutdatedIncomeNotifications.kt b/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/OutdatedIncomeNotifications.kt index 0777ced98f4..4a3a9b18114 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/OutdatedIncomeNotifications.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/OutdatedIncomeNotifications.kt @@ -23,7 +23,7 @@ import fi.espoo.evaka.shared.db.Database import fi.espoo.evaka.shared.domain.DateRange import fi.espoo.evaka.shared.domain.EvakaClock import fi.espoo.evaka.shared.domain.FiniteDateRange -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.springframework.stereotype.Service private val logger = KotlinLogging.logger {} @@ -106,9 +106,9 @@ class OutdatedIncomeNotifications( runAt = clock.now(), ) - logger.info( - "OutdatedIncomeNotification scheduled notification emails: ${guardiansForInitialNotification.size } initial, ${guardiansForReminderNotification.size} reminders and ${guardiansForExpirationNotification.size} expired" - ) + logger.info { + "OutdatedIncomeNotification scheduled notification emails: ${guardiansForInitialNotification.size} initial, ${guardiansForReminderNotification.size} reminders and ${guardiansForExpirationNotification.size} expired" + } return guardiansForInitialNotification.size + guardiansForReminderNotification.size + @@ -139,7 +139,9 @@ class OutdatedIncomeNotifications( } } ?: return - logger.info("OutdatedIncomeNotifications: sending ${msg.type} email to ${msg.guardianId}") + logger.info { + "OutdatedIncomeNotifications: sending ${msg.type} email to ${msg.guardianId}" + } Email.create( dbc = db, diff --git a/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/PaymentService.kt b/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/PaymentService.kt index 0fbbb082728..b68b5fef718 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/PaymentService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/PaymentService.kt @@ -17,8 +17,8 @@ import fi.espoo.evaka.shared.auth.AuthenticatedUser import fi.espoo.evaka.shared.db.Database import fi.espoo.evaka.shared.domain.BadRequest import fi.espoo.evaka.shared.domain.HelsinkiDateTime +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate -import mu.KotlinLogging import org.springframework.stereotype.Component private val logger = KotlinLogging.logger {} diff --git a/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/VoucherValueDecisionService.kt b/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/VoucherValueDecisionService.kt index 66cc8e89da1..910d01f5e08 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/VoucherValueDecisionService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/invoicing/service/VoucherValueDecisionService.kt @@ -44,8 +44,8 @@ import fi.espoo.evaka.shared.domain.EvakaClock import fi.espoo.evaka.shared.domain.NotFound import fi.espoo.evaka.shared.domain.OfficialLanguage import fi.espoo.evaka.shared.message.IMessageProvider +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate -import mu.KotlinLogging import org.springframework.http.ResponseEntity import org.springframework.stereotype.Component diff --git a/service/src/main/kotlin/fi/espoo/evaka/jamix/JamixService.kt b/service/src/main/kotlin/fi/espoo/evaka/jamix/JamixService.kt index 36d6b55f1c0..3af0c806432 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/jamix/JamixService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/jamix/JamixService.kt @@ -40,15 +40,15 @@ import fi.espoo.evaka.shared.domain.FiniteDateRange import fi.espoo.evaka.shared.domain.HelsinkiDateTime import fi.espoo.evaka.shared.domain.getHolidays import fi.espoo.evaka.specialdiet.* +import io.github.oshai.kotlinlogging.KotlinLogging import java.net.URI import java.time.Duration import java.time.LocalDate -import mu.KotlinLogging import org.springframework.stereotype.Service private val logger = KotlinLogging.logger {} -val loggerWarner: (String) -> Unit = { s -> logger.warn(s) } +val loggerWarner: (String) -> Unit = { s -> logger.warn { s } } @Service class JamixService( @@ -157,15 +157,15 @@ fun fetchAndUpdateJamixDiets( val dietsFromJamix = client.getDiets() val cleanedDietList = cleanupJamixDietList(dietsFromJamix) - logger.info( + logger.info { "Jamix returned ${dietsFromJamix.size} cleaned list contains: ${cleanedDietList.size} diets" - ) + } if (cleanedDietList.isEmpty()) error("Refusing to sync empty diet list into database") return db.transaction { tx -> val nulledSpecialDiets = tx.resetSpecialDietsNotContainedWithin(now.toLocalDate(), cleanedDietList) val deletedDietsCount = tx.setSpecialDiets(cleanedDietList) - logger.info("Deleted: $deletedDietsCount diets, inserted ${cleanedDietList.size}") + logger.info { "Deleted: $deletedDietsCount diets, inserted ${cleanedDietList.size}" } if (nulledSpecialDiets.isNotEmpty()) { val byUnit = nulledSpecialDiets.groupBy({ it.unitId }, { it.childId to it.specialDiet }) @@ -208,9 +208,9 @@ fun fetchAndUpdateJamixTextures( "Jamix meal texture list update caused $nulledChildrenCount child meal texture to be set to null" ) val deletedMealTexturesCount = tx.setMealTextures(texturesFromJamix) - logger.info( + logger.info { "Deleted: $deletedMealTexturesCount meal textures, inserted ${texturesFromJamix.size}" - ) + } } } diff --git a/service/src/main/kotlin/fi/espoo/evaka/koski/KoskiClient.kt b/service/src/main/kotlin/fi/espoo/evaka/koski/KoskiClient.kt index b31ceafcc1d..cd56b264f37 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/koski/KoskiClient.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/koski/KoskiClient.kt @@ -21,8 +21,8 @@ import fi.espoo.evaka.shared.async.AsyncJobRunner import fi.espoo.evaka.shared.config.defaultJsonMapperBuilder import fi.espoo.evaka.shared.db.Database import fi.espoo.voltti.logging.loggers.error +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate -import mu.KotlinLogging private val logger = KotlinLogging.logger {} @@ -118,9 +118,9 @@ class KoskiClient( data.operation == KoskiOperation.VOID && errors?.any { it.isNotFound() } == true ) { - logger.warn( + logger.warn { "Koski upload ${msg.key} ${data.operation}: 404 not found -> assuming study right is already voided and nothing needs to be done" - ) + } null } else { val meta = diff --git a/service/src/main/kotlin/fi/espoo/evaka/koski/KoskiUpdateService.kt b/service/src/main/kotlin/fi/espoo/evaka/koski/KoskiUpdateService.kt index f88ccc00979..b56c95dee14 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/koski/KoskiUpdateService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/koski/KoskiUpdateService.kt @@ -9,8 +9,8 @@ import fi.espoo.evaka.shared.async.AsyncJob import fi.espoo.evaka.shared.async.AsyncJobRunner import fi.espoo.evaka.shared.db.Database import fi.espoo.evaka.shared.domain.EvakaClock +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.Duration -import mu.KotlinLogging import org.springframework.stereotype.Service private val logger = KotlinLogging.logger {} diff --git a/service/src/main/kotlin/fi/espoo/evaka/messaging/MessagePushNotifications.kt b/service/src/main/kotlin/fi/espoo/evaka/messaging/MessagePushNotifications.kt index 8ac0d2af105..4224666ecce 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/messaging/MessagePushNotifications.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/messaging/MessagePushNotifications.kt @@ -23,8 +23,8 @@ import fi.espoo.evaka.webpush.WebPushNotification import fi.espoo.evaka.webpush.WebPushPayload import fi.espoo.evaka.webpush.deletePushSubscription import fi.espoo.voltti.logging.loggers.info +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.Duration -import mu.KotlinLogging import org.springframework.stereotype.Service @Service @@ -168,15 +168,15 @@ AND notification.device = ${bind(device)} listOf( WebPushPayload.NotificationV1( title = - "Uusi viesti ryhmälle ${notification.groupName}${notification.senderName?.let { " ($it)"} ?: ""}" + "Uusi viesti ryhmälle ${notification.groupName}${notification.senderName?.let { " ($it)" } ?: ""}" ) ), ), ) } catch (e: WebPush.SubscriptionExpired) { - logger.warn( + logger.warn { "Subscription expired for device $device (HTTP status ${e.status}) -> deleting" - ) + } dbc.transaction { it.deletePushSubscription(device) } } } diff --git a/service/src/main/kotlin/fi/espoo/evaka/messaging/MessageQueries.kt b/service/src/main/kotlin/fi/espoo/evaka/messaging/MessageQueries.kt index 10cd63a5403..400e7c00e4a 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/messaging/MessageQueries.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/messaging/MessageQueries.kt @@ -17,8 +17,8 @@ import fi.espoo.evaka.shared.domain.NotFound import fi.espoo.evaka.shared.domain.formatName import fi.espoo.evaka.shared.security.actionrule.AccessControlFilter import fi.espoo.evaka.shared.security.actionrule.forTable +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate -import mu.KotlinLogging import org.jdbi.v3.json.Json private val logger = KotlinLogging.logger {} @@ -603,7 +603,7 @@ private fun combineThreadsAndMessages( threads.data.flatMap { thread -> val messages = messagesByThread[thread.id] if (messages == null) { - logger.warn("Thread ${thread.id} has no messages for account $accountId") + logger.warn { "Thread ${thread.id} has no messages for account $accountId" } listOf() } else { listOf( diff --git a/service/src/main/kotlin/fi/espoo/evaka/note/child/daily/ChildDailyNoteController.kt b/service/src/main/kotlin/fi/espoo/evaka/note/child/daily/ChildDailyNoteController.kt index 8b8ddec4b95..48111a53c2e 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/note/child/daily/ChildDailyNoteController.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/note/child/daily/ChildDailyNoteController.kt @@ -15,7 +15,7 @@ import fi.espoo.evaka.shared.domain.Conflict import fi.espoo.evaka.shared.domain.EvakaClock import fi.espoo.evaka.shared.security.AccessControl import fi.espoo.evaka.shared.security.Action -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.springframework.web.bind.annotation.DeleteMapping import org.springframework.web.bind.annotation.PathVariable import org.springframework.web.bind.annotation.PostMapping @@ -74,7 +74,7 @@ class ChildDailyNoteController(private val ac: AccessControl) { } catch (e: Exception) { val error = mapPSQLException(e) // monitor if there is issues with stale data or need for upsert - if (error is Conflict) logger.warn("User tried to create a duplicate note for child") + if (error is Conflict) logger.warn { "User tried to create a duplicate note for child" } throw error } } diff --git a/service/src/main/kotlin/fi/espoo/evaka/pedagogicaldocument/PedagogicalDocumentNotificationService.kt b/service/src/main/kotlin/fi/espoo/evaka/pedagogicaldocument/PedagogicalDocumentNotificationService.kt index 72379ea846a..a94c17c4ad7 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/pedagogicaldocument/PedagogicalDocumentNotificationService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/pedagogicaldocument/PedagogicalDocumentNotificationService.kt @@ -16,7 +16,7 @@ import fi.espoo.evaka.shared.async.AsyncJobRunner import fi.espoo.evaka.shared.db.Database import fi.espoo.evaka.shared.domain.EvakaClock import fi.espoo.evaka.shared.domain.HelsinkiDateTime -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.springframework.stereotype.Service private val logger = KotlinLogging.logger {} diff --git a/service/src/main/kotlin/fi/espoo/evaka/pis/InactivePeopleCleanup.kt b/service/src/main/kotlin/fi/espoo/evaka/pis/InactivePeopleCleanup.kt index 471fb87c112..9e70616c485 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/pis/InactivePeopleCleanup.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/pis/InactivePeopleCleanup.kt @@ -7,9 +7,9 @@ package fi.espoo.evaka.pis import fi.espoo.evaka.shared.PersonId import fi.espoo.evaka.shared.db.Database import fi.espoo.voltti.logging.loggers.info +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.Duration import java.time.LocalDate -import mu.KotlinLogging private val logger = KotlinLogging.logger {} diff --git a/service/src/main/kotlin/fi/espoo/evaka/pis/UpdateFromVtjAsyncJobProcessor.kt b/service/src/main/kotlin/fi/espoo/evaka/pis/UpdateFromVtjAsyncJobProcessor.kt index 71effbca2c6..cf0cc75f120 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/pis/UpdateFromVtjAsyncJobProcessor.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/pis/UpdateFromVtjAsyncJobProcessor.kt @@ -12,7 +12,7 @@ import fi.espoo.evaka.shared.async.AsyncJobRunner import fi.espoo.evaka.shared.auth.AuthenticatedUser import fi.espoo.evaka.shared.db.Database import fi.espoo.evaka.shared.domain.EvakaClock -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.springframework.stereotype.Component private val logger = KotlinLogging.logger {} @@ -42,7 +42,7 @@ class UpdateFromVtjAsyncJobProcessor( ) } ?.let { - logger.info("Refreshing all VTJ information for person ${it.id}") + logger.info { "Refreshing all VTJ information for person ${it.id}" } fridgeFamilyService.doVTJRefresh(db, AsyncJob.VTJRefresh(it.id), evakaClock) } } diff --git a/service/src/main/kotlin/fi/espoo/evaka/pis/service/FamilyInitializerService.kt b/service/src/main/kotlin/fi/espoo/evaka/pis/service/FamilyInitializerService.kt index 4daff7bccc0..2a00ec766e7 100755 --- a/service/src/main/kotlin/fi/espoo/evaka/pis/service/FamilyInitializerService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/pis/service/FamilyInitializerService.kt @@ -18,7 +18,7 @@ import fi.espoo.evaka.shared.db.psqlCause import fi.espoo.evaka.shared.domain.DateRange import fi.espoo.evaka.shared.domain.EvakaClock import fi.espoo.evaka.shared.domain.NotFound -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.jdbi.v3.core.statement.UnableToExecuteStatementException import org.postgresql.util.PSQLState import org.springframework.stereotype.Service @@ -240,11 +240,13 @@ class FamilyInitializerService( (it.endDate.isAfter(startDate)) } if (alreadyExists) { - logger.debug("Similar parentship already exists between $headOfChildId and ${child.id}") + logger.debug { + "Similar parentship already exists between $headOfChildId and ${child.id}" + } } else { val endDate = child.dateOfBirth.plusYears(18).minusDays(1) if (startDate > endDate) { - logger.debug("Skipped adding a child that is at least 18 years old to a family") + logger.debug { "Skipped adding a child that is at least 18 years old to a family" } return } try { @@ -263,9 +265,9 @@ class FamilyInitializerService( PSQLState.UNIQUE_VIOLATION.state, PSQLState.EXCLUSION_VIOLATION.state -> { val constraint = e.psqlCause()?.serverErrorMessage?.constraint ?: "-" - logger.warn( + logger.warn { "Creating conflict parentship between $headOfChildId and ${child.id} (conflicting constraint is $constraint)" - ) + } tx.createParentship( childId = child.id, headOfChildId = headOfChildId, @@ -275,6 +277,7 @@ class FamilyInitializerService( conflict = true, ) } + else -> throw e } } @@ -298,7 +301,7 @@ class FamilyInitializerService( (partnership.endDate == null || partnership.endDate.isAfter(startDate)) } if (alreadyExists) { - logger.debug("Similar partnership already exists between $personId1 and $personId2") + logger.debug { "Similar partnership already exists between $personId1 and $personId2" } } else { try { tx.subTransaction { @@ -317,9 +320,9 @@ class FamilyInitializerService( PSQLState.UNIQUE_VIOLATION.state, PSQLState.EXCLUSION_VIOLATION.state -> { val constraint = e.psqlCause()?.serverErrorMessage?.constraint ?: "-" - logger.warn( + logger.warn { "Creating conflict partnership between $personId1 and $personId2 (conflicting constraint is $constraint)" - ) + } tx.createPartnership( personId1 = personId1, personId2 = personId2, @@ -330,6 +333,7 @@ class FamilyInitializerService( evakaClock.now(), ) } + else -> throw e } } diff --git a/service/src/main/kotlin/fi/espoo/evaka/pis/service/FridgeFamilyService.kt b/service/src/main/kotlin/fi/espoo/evaka/pis/service/FridgeFamilyService.kt index b8679a42ebe..75d8079253e 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/pis/service/FridgeFamilyService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/pis/service/FridgeFamilyService.kt @@ -14,9 +14,9 @@ import fi.espoo.evaka.shared.async.AsyncJob import fi.espoo.evaka.shared.auth.AuthenticatedUser import fi.espoo.evaka.shared.db.Database import fi.espoo.evaka.shared.domain.EvakaClock +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate import java.time.Period -import mu.KotlinLogging import org.springframework.stereotype.Service private val logger = KotlinLogging.logger {} @@ -75,7 +75,7 @@ class FridgeFamilyService( clock: EvakaClock, personId: PersonId, ) { - logger.info("Refreshing $personId from VTJ") + logger.info { "Refreshing $personId from VTJ" } val targetPerson = db.transaction { personService.getPersonWithChildren( @@ -86,11 +86,11 @@ class FridgeFamilyService( ) } if (targetPerson != null) { - logger.info("Person to refresh has ${targetPerson.children.size} children") + logger.info { "Person to refresh has ${targetPerson.children.size} children" } val partner = db.read { getPartnerId(it, clock, personId) } - ?.also { logger.info("Person has fridge partner $it") } + ?.also { logger.info { "Person has fridge partner $it" } } ?.let { partnerId -> db.transaction { personService.getPersonWithChildren( @@ -117,13 +117,13 @@ class FridgeFamilyService( else targetPerson if (partner != null) { - logger.info( + logger.info { "Partner lives in the same address and has ${partner.children.size} children" - ) + } if (head == partner) { - logger.info( + logger.info { "Partner has a fridge family, so adding the new children to that family" - ) + } } } @@ -169,9 +169,9 @@ class FridgeFamilyService( Creator.DVV, ) } - logger.info("Child ${child.id} added to head of child ${head.id}") + logger.info { "Child ${child.id} added to head of child ${head.id}" } } catch (e: Exception) { - logger.warn("Problem while adding a child to fridge family:", e) + logger.warn(e) { "Problem while adding a child to fridge family:" } } } } diff --git a/service/src/main/kotlin/fi/espoo/evaka/pis/service/MergeService.kt b/service/src/main/kotlin/fi/espoo/evaka/pis/service/MergeService.kt index f27446a04c9..096cda00884 100755 --- a/service/src/main/kotlin/fi/espoo/evaka/pis/service/MergeService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/pis/service/MergeService.kt @@ -16,8 +16,8 @@ import fi.espoo.evaka.shared.db.mapPSQLException import fi.espoo.evaka.shared.domain.Conflict import fi.espoo.evaka.shared.domain.DateRange import fi.espoo.evaka.shared.domain.EvakaClock +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate -import mu.KotlinLogging import org.springframework.stereotype.Service @Service @@ -115,7 +115,7 @@ ON CONFLICT (thread_id, participant_id) DO UPDATE SET } .execute() } catch (e: Exception) { - logger.warn("Failed to merge persons $master and $duplicate", e) + logger.warn(e) { "Failed to merge persons $master and $duplicate" } throw mapPSQLException(e) } diff --git a/service/src/main/kotlin/fi/espoo/evaka/pis/service/ParentshipService.kt b/service/src/main/kotlin/fi/espoo/evaka/pis/service/ParentshipService.kt index 3c79170d5dc..9b12b148ae8 100755 --- a/service/src/main/kotlin/fi/espoo/evaka/pis/service/ParentshipService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/pis/service/ParentshipService.kt @@ -25,8 +25,8 @@ import fi.espoo.evaka.shared.domain.BadRequest import fi.espoo.evaka.shared.domain.DateRange import fi.espoo.evaka.shared.domain.EvakaClock import fi.espoo.evaka.shared.domain.NotFound +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate -import mu.KotlinLogging import org.springframework.stereotype.Service @Service @@ -126,7 +126,7 @@ class ParentshipService(private val asyncJobRunner: AsyncJobRunner) { startDate: LocalDate, endDate: LocalDate, ) { - logger.info("Sending update family message with adult $adultId") + logger.info { "Sending update family message with adult $adultId" } asyncJobRunner.plan( this, listOf( diff --git a/service/src/main/kotlin/fi/espoo/evaka/pis/service/PersonService.kt b/service/src/main/kotlin/fi/espoo/evaka/pis/service/PersonService.kt index 74405de7be1..7cb25cbb650 100755 --- a/service/src/main/kotlin/fi/espoo/evaka/pis/service/PersonService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/pis/service/PersonService.kt @@ -39,8 +39,8 @@ import fi.espoo.evaka.vtjclient.dto.Nationality import fi.espoo.evaka.vtjclient.dto.NativeLanguage import fi.espoo.evaka.vtjclient.dto.VtjPersonDTO import fi.espoo.evaka.vtjclient.service.persondetails.IPersonDetailsService +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate -import mu.KotlinLogging import org.springframework.stereotype.Service import org.thymeleaf.context.Context @@ -613,7 +613,7 @@ private fun upsertVtjGuardians(tx: Database.Transaction, vtjPersonDTO: VtjPerson .map { upsertVtjPerson(tx, it) } .filterNot { tx.isGuardianBlocked(it.id, child.id) } createOrReplaceChildRelationships(tx, childId = child.id, guardianIds = guardians.map { it.id }) - logger.info("Created or replaced child ${child.id} guardians as ${guardians.map { it.id }}") + logger.info { "Created or replaced child ${child.id} guardians as ${guardians.map { it.id }}" } return child.toVtjPersonDTO().copy(guardians = guardians.map { it.toVtjPersonDTO() }) } @@ -628,7 +628,9 @@ private fun upsertVtjChildren(tx: Database.Transaction, vtjPersonDTO: VtjPersonD guardianId = guardian.id, childIds = children.map { it.id }, ) - logger.info("Created or replaced guardian ${guardian.id} children as ${children.map { it.id }}") + logger.info { + "Created or replaced guardian ${guardian.id} children as ${children.map { it.id }}" + } return guardian.toVtjPersonDTO().copy(children = children.map { it.toVtjPersonDTO() }) } diff --git a/service/src/main/kotlin/fi/espoo/evaka/placement/PlacementPlanService.kt b/service/src/main/kotlin/fi/espoo/evaka/placement/PlacementPlanService.kt index 60efd84c864..55c409a03ad 100755 --- a/service/src/main/kotlin/fi/espoo/evaka/placement/PlacementPlanService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/placement/PlacementPlanService.kt @@ -27,10 +27,10 @@ import fi.espoo.evaka.shared.domain.EvakaClock import fi.espoo.evaka.shared.domain.FiniteDateRange import fi.espoo.evaka.shared.domain.HelsinkiDateTime import fi.espoo.evaka.shared.domain.NotFound +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate import java.time.Month import java.util.UUID -import mu.KotlinLogging import org.springframework.stereotype.Service private val logger = KotlinLogging.logger {} diff --git a/service/src/main/kotlin/fi/espoo/evaka/reports/patu/EspooPatuIntegrationClient.kt b/service/src/main/kotlin/fi/espoo/evaka/reports/patu/EspooPatuIntegrationClient.kt index 29b16fe2c2b..998d30c1e92 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/reports/patu/EspooPatuIntegrationClient.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/reports/patu/EspooPatuIntegrationClient.kt @@ -12,7 +12,7 @@ import com.github.kittinunf.fuel.core.extensions.jsonBody import com.github.kittinunf.result.Result import fi.espoo.evaka.EspooPatuIntegrationEnv import fi.espoo.evaka.reports.RawReportRow -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging private val logger = KotlinLogging.logger {} @@ -23,7 +23,7 @@ class EspooPatuIntegrationClient( private val fuel = FuelManager() override fun send(patuReport: List): PatuIntegrationClient.Result { - logger.info("Sending patu report of ${patuReport.size} rows") + logger.info { "Sending patu report of ${patuReport.size} rows" } val payload = jsonMapper.writeValueAsString(patuReport) val (_, _, result) = fuel diff --git a/service/src/main/kotlin/fi/espoo/evaka/reports/patu/PatuAsyncJobProcessor.kt b/service/src/main/kotlin/fi/espoo/evaka/reports/patu/PatuAsyncJobProcessor.kt index e2dbca4de1d..1f926503038 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/reports/patu/PatuAsyncJobProcessor.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/reports/patu/PatuAsyncJobProcessor.kt @@ -7,7 +7,7 @@ package fi.espoo.evaka.reports.patu import fi.espoo.evaka.shared.async.AsyncJob import fi.espoo.evaka.shared.async.AsyncJobRunner import fi.espoo.evaka.shared.db.Database -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging private val logger = KotlinLogging.logger {} @@ -22,7 +22,7 @@ class PatuAsyncJobProcessor( } fun runSendPatuReport(dbc: Database.Connection, msg: AsyncJob.SendPatuReport) { - logger.info("Running patu report job ${msg.dateRange}") + logger.info { "Running patu report job ${msg.dateRange}" } patuReportingService.sendPatuReport(dbc, msg.dateRange) } } diff --git a/service/src/main/kotlin/fi/espoo/evaka/reports/patu/PatuIntegrationClient.kt b/service/src/main/kotlin/fi/espoo/evaka/reports/patu/PatuIntegrationClient.kt index 2be440fb7d4..5f1f5cc0d74 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/reports/patu/PatuIntegrationClient.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/reports/patu/PatuIntegrationClient.kt @@ -6,7 +6,7 @@ package fi.espoo.evaka.reports.patu import com.fasterxml.jackson.databind.json.JsonMapper import fi.espoo.evaka.reports.RawReportRow -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging private val logger = KotlinLogging.logger {} @@ -17,9 +17,9 @@ interface PatuIntegrationClient { class MockPatuClient(private val jsonMapper: JsonMapper) : PatuIntegrationClient { override fun send(patuReport: List): Result { - logger.info( + logger.info { "Mock patu client got report rows ${jsonMapper.writeValueAsString(patuReport)}" - ) + } return Result(true) } } diff --git a/service/src/main/kotlin/fi/espoo/evaka/reports/patu/PatuReportingController.kt b/service/src/main/kotlin/fi/espoo/evaka/reports/patu/PatuReportingController.kt index f8a738b574b..ffb091d9b1b 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/reports/patu/PatuReportingController.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/reports/patu/PatuReportingController.kt @@ -14,8 +14,8 @@ import fi.espoo.evaka.shared.domain.EvakaClock import fi.espoo.evaka.shared.domain.HelsinkiDateTime import fi.espoo.evaka.shared.security.AccessControl import fi.espoo.evaka.shared.security.Action +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate -import mu.KotlinLogging import org.springframework.format.annotation.DateTimeFormat import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestMapping @@ -43,7 +43,7 @@ class PatuReportingController( db.connect { dbc -> dbc.transaction { tx -> accessControl.requirePermissionFor(tx, user, clock, Action.Global.SEND_PATU_REPORT) - logger.info("Scheduling patu report $range") + logger.info { "Scheduling patu report $range" } asyncJobRunner.plan( tx, payloads = listOf(AsyncJob.SendPatuReport(range)), diff --git a/service/src/main/kotlin/fi/espoo/evaka/reservations/MissingHolidayReservationsReminders.kt b/service/src/main/kotlin/fi/espoo/evaka/reservations/MissingHolidayReservationsReminders.kt index f58333f2913..1cf71a60a5f 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/reservations/MissingHolidayReservationsReminders.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/reservations/MissingHolidayReservationsReminders.kt @@ -20,8 +20,8 @@ import fi.espoo.evaka.shared.async.AsyncJobType import fi.espoo.evaka.shared.async.removeUnclaimedJobs import fi.espoo.evaka.shared.db.Database import fi.espoo.evaka.shared.domain.EvakaClock +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate -import mu.KotlinLogging import org.springframework.stereotype.Service @Service @@ -50,9 +50,9 @@ class MissingHolidayReservationsReminders( return tx.getHolidayPeriodsWithReservationDeadline(clock.today().plusDays(2)) .firstOrNull() ?.let { holidayPeriod -> - logger.info( + logger.info { "Holiday ${holidayPeriod.id} reservation deadline is due, sending missing reservation reminders" - ) + } val childrenWithMaybeMissingHolidayReservations = holidayPeriod.period @@ -68,9 +68,9 @@ class MissingHolidayReservationsReminders( ) .toSet() - logger.info( + logger.info { "Got ${childrenWithMaybeMissingHolidayReservations.size} children with maybe missing holiday reservations and will notify ${personsToBeNotified.size} persons for holiday ${holidayPeriod.period}" - ) + } asyncJobRunner.plan( tx, @@ -154,7 +154,7 @@ WHERE p.id = ANY(${bind(childIds)}) val receiver = db.read { tx -> tx.getPersonById(msg.guardian) } if (receiver == null) { - logger.warn("Person ${msg.guardian} not found when sending email!") + logger.warn { "Person ${msg.guardian} not found when sending email!" } return } diff --git a/service/src/main/kotlin/fi/espoo/evaka/serviceneed/application/ServiceApplicationService.kt b/service/src/main/kotlin/fi/espoo/evaka/serviceneed/application/ServiceApplicationService.kt index 82e75bc9561..fc99ad5cd00 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/serviceneed/application/ServiceApplicationService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/serviceneed/application/ServiceApplicationService.kt @@ -17,7 +17,7 @@ import fi.espoo.evaka.shared.async.AsyncJobRunner import fi.espoo.evaka.shared.db.Database import fi.espoo.evaka.shared.domain.EvakaClock import fi.espoo.evaka.shared.domain.NotFound -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.springframework.stereotype.Service private val logger = KotlinLogging.logger {} diff --git a/service/src/main/kotlin/fi/espoo/evaka/sficlient/MockSfiMessagesClient.kt b/service/src/main/kotlin/fi/espoo/evaka/sficlient/MockSfiMessagesClient.kt index 87890820d96..99d02c287a5 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/sficlient/MockSfiMessagesClient.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/sficlient/MockSfiMessagesClient.kt @@ -4,10 +4,10 @@ package fi.espoo.evaka.sficlient +import io.github.oshai.kotlinlogging.KotlinLogging import java.util.concurrent.locks.ReentrantReadWriteLock import kotlin.concurrent.read import kotlin.concurrent.write -import mu.KotlinLogging private typealias MessageId = String @@ -15,7 +15,7 @@ class MockSfiMessagesClient : SfiMessagesClient { private val logger = KotlinLogging.logger {} override fun send(msg: SfiMessage) { - logger.info("Mock message client got $msg") + logger.info { "Mock message client got $msg" } lock.write { data[msg.messageId] = msg } } diff --git a/service/src/main/kotlin/fi/espoo/evaka/sficlient/SfiMessagesSoapClient.kt b/service/src/main/kotlin/fi/espoo/evaka/sficlient/SfiMessagesSoapClient.kt index 4691884d4be..3e1647f611c 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/sficlient/SfiMessagesSoapClient.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/sficlient/SfiMessagesSoapClient.kt @@ -22,13 +22,13 @@ import fi.espoo.evaka.sficlient.soap.Yhteyshenkilo import fi.espoo.evaka.shared.domain.europeHelsinki import fi.espoo.voltti.logging.loggers.error import fi.espoo.voltti.logging.loggers.info +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate import java.time.ZoneId import java.util.GregorianCalendar import javax.net.ssl.TrustManagerFactory import javax.xml.datatype.DatatypeFactory import javax.xml.datatype.XMLGregorianCalendar -import mu.KotlinLogging import org.apache.commons.text.StringEscapeUtils import org.apache.wss4j.common.crypto.Merlin import org.apache.wss4j.dom.WSConstants diff --git a/service/src/main/kotlin/fi/espoo/evaka/sficlient/rest/PasswordStore.kt b/service/src/main/kotlin/fi/espoo/evaka/sficlient/rest/PasswordStore.kt index 6f8d8468649..479aed9e375 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/sficlient/rest/PasswordStore.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/sficlient/rest/PasswordStore.kt @@ -6,7 +6,7 @@ package fi.espoo.evaka.sficlient.rest import fi.espoo.evaka.Sensitive import fi.espoo.evaka.SfiEnv -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import software.amazon.awssdk.services.ssm.SsmClient import software.amazon.awssdk.services.ssm.model.GetParameterRequest import software.amazon.awssdk.services.ssm.model.LabelParameterVersionRequest diff --git a/service/src/main/kotlin/fi/espoo/evaka/sficlient/rest/SfiMessagesRestClient.kt b/service/src/main/kotlin/fi/espoo/evaka/sficlient/rest/SfiMessagesRestClient.kt index 1ad5ea0a6ba..07c44723bce 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/sficlient/rest/SfiMessagesRestClient.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/sficlient/rest/SfiMessagesRestClient.kt @@ -13,8 +13,8 @@ import fi.espoo.evaka.sficlient.SfiMessage import fi.espoo.evaka.sficlient.SfiMessagesClient import fi.espoo.evaka.shared.config.defaultJsonMapperBuilder import fi.espoo.voltti.logging.loggers.info +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.Duration -import mu.KotlinLogging import okhttp3.HttpUrl.Companion.toHttpUrlOrNull import okhttp3.MediaType.Companion.toMediaType import okhttp3.OkHttpClient diff --git a/service/src/main/kotlin/fi/espoo/evaka/shared/async/AsyncJobPool.kt b/service/src/main/kotlin/fi/espoo/evaka/shared/async/AsyncJobPool.kt index 79be970f0fe..3abb9a8e81d 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/shared/async/AsyncJobPool.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/shared/async/AsyncJobPool.kt @@ -14,6 +14,7 @@ import fi.espoo.evaka.shared.withValue import fi.espoo.voltti.logging.MdcKey import fi.espoo.voltti.logging.loggers.error import fi.espoo.voltti.logging.loggers.info +import io.github.oshai.kotlinlogging.KotlinLogging import io.micrometer.core.instrument.Counter import io.micrometer.core.instrument.Gauge import io.micrometer.core.instrument.MeterRegistry @@ -30,7 +31,6 @@ import java.util.concurrent.atomic.AtomicInteger import java.util.concurrent.atomic.AtomicReference import kotlin.concurrent.thread import kotlin.reflect.KClass -import mu.KotlinLogging import org.jdbi.v3.core.Jdbi class AsyncJobPool( diff --git a/service/src/main/kotlin/fi/espoo/evaka/shared/async/AsyncJobQueries.kt b/service/src/main/kotlin/fi/espoo/evaka/shared/async/AsyncJobQueries.kt index 865b44a9618..2136c8de57a 100755 --- a/service/src/main/kotlin/fi/espoo/evaka/shared/async/AsyncJobQueries.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/shared/async/AsyncJobQueries.kt @@ -6,8 +6,8 @@ package fi.espoo.evaka.shared.async import fi.espoo.evaka.shared.db.Database import fi.espoo.evaka.shared.domain.HelsinkiDateTime +import io.github.oshai.kotlinlogging.KotlinLogging import java.util.UUID -import mu.KotlinLogging import org.jdbi.v3.core.qualifier.QualifiedType import org.jdbi.v3.json.Json @@ -196,5 +196,5 @@ fun Database.Connection.removeOldAsyncJobs(now: HelsinkiDateTime) { val runBefore = now.minusMonths(6) val oldCount = transaction { it.removeUncompletedJobs(runBefore = runBefore) } - logger.info("Removed $oldCount async jobs originally planned to be run before $runBefore") + logger.info { "Removed $oldCount async jobs originally planned to be run before $runBefore" } } diff --git a/service/src/main/kotlin/fi/espoo/evaka/shared/async/AsyncJobRunner.kt b/service/src/main/kotlin/fi/espoo/evaka/shared/async/AsyncJobRunner.kt index 507d800247a..7df06a27d0a 100755 --- a/service/src/main/kotlin/fi/espoo/evaka/shared/async/AsyncJobRunner.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/shared/async/AsyncJobRunner.kt @@ -8,6 +8,7 @@ import fi.espoo.evaka.shared.db.Database import fi.espoo.evaka.shared.domain.EvakaClock import fi.espoo.evaka.shared.domain.HelsinkiDateTime import fi.espoo.evaka.shared.domain.RealEvakaClock +import io.github.oshai.kotlinlogging.KotlinLogging import io.micrometer.core.instrument.MeterRegistry import io.opentelemetry.api.trace.Tracer import java.time.Duration @@ -21,7 +22,6 @@ import kotlin.concurrent.read import kotlin.concurrent.write import kotlin.math.max import kotlin.reflect.KClass -import mu.KotlinLogging import org.jdbi.v3.core.Jdbi private const val defaultRetryCount = diff --git a/service/src/main/kotlin/fi/espoo/evaka/shared/config/AsyncJobConfig.kt b/service/src/main/kotlin/fi/espoo/evaka/shared/config/AsyncJobConfig.kt index 69f371ea6c5..2083f8df973 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/shared/config/AsyncJobConfig.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/shared/config/AsyncJobConfig.kt @@ -7,10 +7,10 @@ package fi.espoo.evaka.shared.config import fi.espoo.evaka.EvakaEnv import fi.espoo.evaka.shared.async.AsyncJob import fi.espoo.evaka.shared.async.AsyncJobRunner +import io.github.oshai.kotlinlogging.KotlinLogging import io.micrometer.core.instrument.MeterRegistry import io.opentelemetry.api.trace.Tracer import java.time.Duration -import mu.KotlinLogging import org.jdbi.v3.core.Jdbi import org.springframework.boot.context.event.ApplicationReadyEvent import org.springframework.context.ApplicationListener @@ -52,13 +52,13 @@ class AsyncJobConfig { ApplicationListener { val logger = KotlinLogging.logger {} if (evakaEnv.asyncJobRunnerDisabled) { - logger.info("Async job runners disabled") + logger.info { "Async job runners disabled" } } else { asyncJobRunners.forEach { it.registerMeters(meterRegistry) it.enableAfterCommitHooks() it.startBackgroundPolling() - logger.info("Async job runner ${it.name} started") + logger.info { "Async job runner ${it.name} started" } } } } diff --git a/service/src/main/kotlin/fi/espoo/evaka/shared/config/SfiConfig.kt b/service/src/main/kotlin/fi/espoo/evaka/shared/config/SfiConfig.kt index b5d3f8e82a6..9cbb27c65a1 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/shared/config/SfiConfig.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/shared/config/SfiConfig.kt @@ -11,7 +11,7 @@ import fi.espoo.evaka.sficlient.SfiMessagesClient import fi.espoo.evaka.sficlient.SfiMessagesSoapClient import fi.espoo.evaka.sficlient.rest.AwsSsmPasswordStore import fi.espoo.evaka.sficlient.rest.SfiMessagesRestClient -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.springframework.beans.factory.ObjectProvider import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration diff --git a/service/src/main/kotlin/fi/espoo/evaka/shared/db/SanityChecks.kt b/service/src/main/kotlin/fi/espoo/evaka/shared/db/SanityChecks.kt index 5660344d50e..f594c20e4e4 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/shared/db/SanityChecks.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/shared/db/SanityChecks.kt @@ -5,8 +5,8 @@ package fi.espoo.evaka.shared.db import fi.espoo.evaka.shared.domain.EvakaClock +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate -import mu.KotlinLogging private val logger = KotlinLogging.logger {} @@ -18,9 +18,9 @@ fun runSanityChecks(tx: Database.Read, clock: EvakaClock) { private fun logResult(description: String, violations: Int) { if (violations > 0) { - logger.warn("Sanity check failed - $description: $violations instances") + logger.warn { "Sanity check failed - $description: $violations instances" } } else { - logger.info("Sanity check passed - $description") + logger.info { "Sanity check passed - $description" } } } diff --git a/service/src/main/kotlin/fi/espoo/evaka/shared/dev/DataInitializers.kt b/service/src/main/kotlin/fi/espoo/evaka/shared/dev/DataInitializers.kt index f32fede8cd1..6c19f374e4d 100755 --- a/service/src/main/kotlin/fi/espoo/evaka/shared/dev/DataInitializers.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/shared/dev/DataInitializers.kt @@ -97,12 +97,12 @@ import fi.espoo.evaka.shared.domain.TimeRange import fi.espoo.evaka.shared.domain.europeHelsinki import fi.espoo.evaka.shared.security.upsertCitizenUser import fi.espoo.evaka.shared.security.upsertEmployeeUser +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.Instant import java.time.LocalDate import java.time.LocalTime import java.time.YearMonth import java.util.UUID -import mu.KotlinLogging import org.jdbi.v3.json.Json import org.springframework.core.io.ClassPathResource @@ -110,7 +110,7 @@ private val logger = KotlinLogging.logger {} fun Database.Transaction.runDevScript(devScriptName: String) { val path = "dev-data/$devScriptName" - logger.info("Running SQL script: $path") + logger.info { "Running SQL script: $path" } ClassPathResource(path).inputStream.use { it.bufferedReader().readText().let { content -> execute { sql(content) } } } diff --git a/service/src/main/kotlin/fi/espoo/evaka/shared/dev/DevApi.kt b/service/src/main/kotlin/fi/espoo/evaka/shared/dev/DevApi.kt index e0d7985b5c6..cd531d54d04 100755 --- a/service/src/main/kotlin/fi/espoo/evaka/shared/dev/DevApi.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/shared/dev/DevApi.kt @@ -205,6 +205,7 @@ import fi.espoo.evaka.vtjclient.dto.VtjPerson import fi.espoo.evaka.vtjclient.service.persondetails.MockPersonDetailsService import fi.espoo.evaka.vtjclient.service.persondetails.MockVtjDataset import fi.espoo.evaka.webpush.PushNotificationCategory +import io.github.oshai.kotlinlogging.KotlinLogging import java.math.BigDecimal import java.time.Duration import java.time.Instant @@ -212,7 +213,6 @@ import java.time.LocalDate import java.time.LocalTime import java.util.UUID import java.util.concurrent.TimeUnit -import mu.KotlinLogging import org.jdbi.v3.core.mapper.Nested import org.jdbi.v3.core.statement.UnableToExecuteStatementException import org.jdbi.v3.json.Json diff --git a/service/src/main/kotlin/fi/espoo/evaka/shared/job/ScheduledJobRunner.kt b/service/src/main/kotlin/fi/espoo/evaka/shared/job/ScheduledJobRunner.kt index dd788cbd126..3ef0b8f5775 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/shared/job/ScheduledJobRunner.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/shared/job/ScheduledJobRunner.kt @@ -14,10 +14,10 @@ import fi.espoo.evaka.shared.domain.EvakaClock import fi.espoo.evaka.shared.domain.HelsinkiDateTime import fi.espoo.evaka.shared.withDetachedSpan import fi.espoo.voltti.logging.loggers.info +import io.github.oshai.kotlinlogging.KotlinLogging import io.opentelemetry.api.trace.Tracer import java.time.Duration import javax.sql.DataSource -import mu.KotlinLogging import org.jdbi.v3.core.Jdbi private const val SCHEDULER_THREADS = 1 diff --git a/service/src/main/kotlin/fi/espoo/evaka/shared/job/ScheduledJobs.kt b/service/src/main/kotlin/fi/espoo/evaka/shared/job/ScheduledJobs.kt index 1465c973823..755a8ccf8af 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/shared/job/ScheduledJobs.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/shared/job/ScheduledJobs.kt @@ -38,8 +38,8 @@ import fi.espoo.evaka.shared.db.runSanityChecks import fi.espoo.evaka.shared.domain.EvakaClock import fi.espoo.evaka.titania.cleanTitaniaErrors import fi.espoo.evaka.varda.new.VardaUpdateServiceNew +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalTime -import mu.KotlinLogging import org.springframework.stereotype.Component enum class ScheduledJob( @@ -400,28 +400,28 @@ WHERE id IN (SELECT id FROM attendances_to_end) fun sendMissingReservationReminders(db: Database.Connection, clock: EvakaClock) { db.transaction { tx -> val count = missingReservationsReminders.scheduleReminders(tx, clock) - logger.info("Scheduled $count reminders about missing reservations") + logger.info { "Scheduled $count reminders about missing reservations" } } } fun sendMissingHolidayReservationReminders(db: Database.Connection, clock: EvakaClock) { db.transaction { tx -> val count = missingHolidayReservationsReminders.scheduleReminders(tx, clock) - logger.info("Scheduled $count reminders about missing holiday reservations") + logger.info { "Scheduled $count reminders about missing holiday reservations" } } } fun sendOutdatedIncomeNotifications(db: Database.Connection, clock: EvakaClock) { db.transaction { tx -> val count = outdatedIncomeNotifications.scheduleNotifications(tx, clock) - logger.info("Scheduled $count notifications about outdated income") + logger.info { "Scheduled $count notifications about outdated income" } } } fun sendNewCustomerIncomeNotifications(db: Database.Connection, clock: EvakaClock) { db.transaction { tx -> val count = newCustomerIncomeNotification.scheduleNotifications(tx, clock) - logger.info("Scheduled $count notifications for new customer about income") + logger.info { "Scheduled $count notifications for new customer about income" } } } diff --git a/service/src/main/kotlin/fi/espoo/evaka/shared/utils/FuelExtensions.kt b/service/src/main/kotlin/fi/espoo/evaka/shared/utils/FuelExtensions.kt index 75b0937e638..75f0e707fd1 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/shared/utils/FuelExtensions.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/shared/utils/FuelExtensions.kt @@ -11,8 +11,8 @@ import com.github.kittinunf.fuel.core.Response import com.github.kittinunf.fuel.core.ResponseResultOf import com.github.kittinunf.fuel.core.extensions.AuthenticatedRequest import com.github.kittinunf.result.Result +import io.github.oshai.kotlinlogging.KotlinLogging import java.util.concurrent.TimeUnit -import mu.KotlinLogging typealias ErrorResponseResultOf = Triple> @@ -102,9 +102,9 @@ fun Request.responseStringWithRetries( ) if (retryAfter > retryWaitLoggingThresholdSeconds) { - logger.warn( + logger.warn { "Waiting for a large RETRY_AFTER as requested: $retryAfter seconds" - ) + } } TimeUnit.SECONDS.sleep(retryAfter) diff --git a/service/src/main/kotlin/fi/espoo/evaka/titania/TitaniaController.kt b/service/src/main/kotlin/fi/espoo/evaka/titania/TitaniaController.kt index 8fb17e68368..0d576861ffd 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/titania/TitaniaController.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/titania/TitaniaController.kt @@ -6,8 +6,8 @@ package fi.espoo.evaka.titania import fi.espoo.evaka.shared.auth.AuthenticatedUser import fi.espoo.evaka.shared.db.Database +import io.github.oshai.kotlinlogging.KotlinLogging import jakarta.servlet.http.HttpServletRequest -import mu.KotlinLogging import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.ExceptionHandler diff --git a/service/src/main/kotlin/fi/espoo/evaka/titania/TitaniaService.kt b/service/src/main/kotlin/fi/espoo/evaka/titania/TitaniaService.kt index 64227f3303a..a73c22bf3fa 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/titania/TitaniaService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/titania/TitaniaService.kt @@ -10,11 +10,11 @@ import fi.espoo.evaka.shared.EmployeeId import fi.espoo.evaka.shared.db.Database import fi.espoo.evaka.shared.domain.HelsinkiDateTime import fi.espoo.evaka.shared.domain.HelsinkiDateTimeRange +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.Duration import java.time.LocalTime import java.time.format.DateTimeFormatter import java.time.temporal.ChronoUnit -import mu.KotlinLogging import org.springframework.stereotype.Service private val logger = KotlinLogging.logger {} diff --git a/service/src/main/kotlin/fi/espoo/evaka/varda/VardaUnits.kt b/service/src/main/kotlin/fi/espoo/evaka/varda/VardaUnits.kt index 670d3e65a4d..6f46d7f6d7a 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/varda/VardaUnits.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/varda/VardaUnits.kt @@ -13,10 +13,10 @@ import fi.espoo.evaka.shared.db.DatabaseEnum import fi.espoo.evaka.shared.domain.EvakaClock import fi.espoo.evaka.shared.domain.HelsinkiDateTime import fi.espoo.evaka.varda.new.VardaEntity +import io.github.oshai.kotlinlogging.KotlinLogging import java.net.URI import java.time.LocalDate import java.util.UUID -import mu.KotlinLogging import org.jdbi.v3.core.result.UnableToProduceResultException private val logger = KotlinLogging.logger {} @@ -87,7 +87,7 @@ fun updateUnits( ) } } catch (e: Exception) { - logger.error("Failed to update unit ${request.nimi}: $e", e) + logger.error(e) { "Failed to update unit ${request.nimi}: $e" } dbc.transaction { setUnitUploadFailed( tx = it, diff --git a/service/src/main/kotlin/fi/espoo/evaka/varda/new/VardaClient.kt b/service/src/main/kotlin/fi/espoo/evaka/varda/new/VardaClient.kt index 385ec1c92ea..69666ca5deb 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/varda/new/VardaClient.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/varda/new/VardaClient.kt @@ -10,10 +10,10 @@ import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.module.kotlin.readValue import fi.espoo.evaka.varda.VardaUnitClient import fi.espoo.evaka.varda.VardaUnitRequest +import io.github.oshai.kotlinlogging.KotlinLogging import java.net.URI import java.net.URLEncoder import java.time.LocalDate -import mu.KotlinLogging import okhttp3.MediaType.Companion.toMediaType import okhttp3.OkHttpClient import okhttp3.Request @@ -327,7 +327,7 @@ class VardaClient( override fun delete(data: T) = request("DELETE", data.url) private inline fun request(method: String, url: URI, body: Any? = null): R { - logger.info("requesting $method $url" + if (body == null) "" else " with body $body") + logger.info { "requesting $method $url" + if (body == null) "" else " with body $body" } val req = Request.Builder() diff --git a/service/src/main/kotlin/fi/espoo/evaka/varda/new/VardaUpdateServiceNew.kt b/service/src/main/kotlin/fi/espoo/evaka/varda/new/VardaUpdateServiceNew.kt index 7b1914def17..52b09939c7b 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/varda/new/VardaUpdateServiceNew.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/varda/new/VardaUpdateServiceNew.kt @@ -18,10 +18,10 @@ import fi.espoo.evaka.shared.domain.FiniteDateRange import fi.espoo.evaka.shared.domain.HelsinkiDateTime import fi.espoo.evaka.varda.updateUnits import fi.espoo.voltti.logging.loggers.info +import io.github.oshai.kotlinlogging.KotlinLogging import java.net.URI import java.time.Duration import java.time.LocalDate -import mu.KotlinLogging import okhttp3.OkHttpClient import org.springframework.stereotype.Service diff --git a/service/src/main/kotlin/fi/espoo/evaka/vtjclient/config/XroadSoapClientConfig.kt b/service/src/main/kotlin/fi/espoo/evaka/vtjclient/config/XroadSoapClientConfig.kt index 023edccfc99..c6559b52bdf 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/vtjclient/config/XroadSoapClientConfig.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/vtjclient/config/XroadSoapClientConfig.kt @@ -10,8 +10,8 @@ import fi.espoo.evaka.vtjclient.mapper.toServiceHeader import fi.espoo.evaka.vtjclient.service.vtjclient.IVtjClientService.VTJQuery import fi.espoo.evaka.vtjclient.soap.ObjectFactory import fi.espoo.voltti.logging.MdcKey +import io.github.oshai.kotlinlogging.KotlinLogging import jakarta.xml.bind.helpers.DefaultValidationEventHandler -import mu.KotlinLogging import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean import org.springframework.context.annotation.Bean @@ -74,14 +74,13 @@ class XroadSoapClientConfig { override fun resolveFault(message: WebServiceMessage) { when (message) { is FaultAwareWebServiceMessage -> { - logger.error( - "Fault while doing X-Road request: ${message.faultCode}. Reason: ${message.faultReason}", - message, - ) + logger.error { + "Fault while doing X-Road request: ${message.faultCode}. Reason: ${message.faultReason}" + } throw WebServiceFaultException(message) } else -> { - logger.error("Unknown error while doing X-Road request: \"$message\".", message) + logger.error { "Unknown error while doing X-Road request: \"$message\"." } throw WebServiceFaultException("Message has unknown fault: $message") } } diff --git a/service/src/main/kotlin/fi/espoo/evaka/vtjclient/mapper/VtjHenkiloMapper.kt b/service/src/main/kotlin/fi/espoo/evaka/vtjclient/mapper/VtjHenkiloMapper.kt index b638e5097a0..be094c367a7 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/vtjclient/mapper/VtjHenkiloMapper.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/vtjclient/mapper/VtjHenkiloMapper.kt @@ -12,10 +12,10 @@ import fi.espoo.evaka.vtjclient.dto.RestrictedDetails import fi.espoo.evaka.vtjclient.dto.VtjPerson import fi.espoo.evaka.vtjclient.soap.VTJHenkiloVastaussanoma import fi.espoo.evaka.vtjclient.soap.VTJHenkiloVastaussanoma.Henkilo +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.LocalDate import java.time.format.DateTimeFormatter import java.time.format.DateTimeParseException -import mu.KotlinLogging import org.springframework.stereotype.Service private val logger = KotlinLogging.logger {} @@ -196,7 +196,7 @@ fun parseLocalDateFromString(date: String?): LocalDate? { return try { LocalDate.parse(date, DateTimeFormatter.BASIC_ISO_DATE) } catch (e: DateTimeParseException) { - logger.error("Error parsing $date as a date", e) + logger.error(e) { "Error parsing $date as a date" } null } } diff --git a/service/src/main/kotlin/fi/espoo/evaka/vtjclient/service/vtjclient/VtjClientService.kt b/service/src/main/kotlin/fi/espoo/evaka/vtjclient/service/vtjclient/VtjClientService.kt index efd60e68a50..76b998a12e4 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/vtjclient/service/vtjclient/VtjClientService.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/vtjclient/service/vtjclient/VtjClientService.kt @@ -18,8 +18,8 @@ import fi.espoo.evaka.vtjclient.soap.HenkiloTunnusKyselyResBody import fi.espoo.evaka.vtjclient.soap.ObjectFactory import fi.espoo.evaka.vtjclient.soap.VTJHenkiloVastaussanoma.Henkilo import fi.espoo.voltti.logging.loggers.auditVTJ +import io.github.oshai.kotlinlogging.KotlinLogging import jakarta.xml.bind.JAXBElement -import mu.KotlinLogging import org.springframework.context.annotation.Profile import org.springframework.stereotype.Service import org.springframework.ws.client.core.WebServiceMessageCallback diff --git a/service/src/main/kotlin/fi/espoo/evaka/webpush/WebPush.kt b/service/src/main/kotlin/fi/espoo/evaka/webpush/WebPush.kt index 10e6f1e68c1..988724fe750 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/webpush/WebPush.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/webpush/WebPush.kt @@ -15,11 +15,11 @@ import fi.espoo.evaka.shared.db.Database import fi.espoo.evaka.shared.domain.EvakaClock import fi.espoo.evaka.shared.utils.writerFor import fi.espoo.voltti.logging.loggers.error +import io.github.oshai.kotlinlogging.KotlinLogging import java.net.URI import java.security.SecureRandom import java.security.interfaces.ECPublicKey import java.time.Duration -import mu.KotlinLogging import org.springframework.http.HttpStatus data class WebPushNotification(