diff --git a/build.gradle.kts b/build.gradle.kts index e77003a0..af6a45d5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -245,7 +245,6 @@ tasks { detekt { buildUponDefaultConfig = true parallel = true - ignoreFailures = true config.setFrom(files(rootDir.resolve("detekt.yml"))) } diff --git a/src/javaMain/kotlin/io/github/oshai/kotlinlogging/slf4j/internal/LocationAwareKLogger.kt b/src/javaMain/kotlin/io/github/oshai/kotlinlogging/slf4j/internal/LocationAwareKLogger.kt index c5dfeefd..eb4d5110 100644 --- a/src/javaMain/kotlin/io/github/oshai/kotlinlogging/slf4j/internal/LocationAwareKLogger.kt +++ b/src/javaMain/kotlin/io/github/oshai/kotlinlogging/slf4j/internal/LocationAwareKLogger.kt @@ -1,12 +1,8 @@ -@file:Suppress("TooManyFunctions") +@file:Suppress("PrivatePropertyName", "TooManyFunctions", "VariableNaming") package io.github.oshai.kotlinlogging.slf4j.internal -import io.github.oshai.kotlinlogging.DelegatingKLogger -import io.github.oshai.kotlinlogging.KLogger -import io.github.oshai.kotlinlogging.KLoggingEventBuilder -import io.github.oshai.kotlinlogging.Level -import io.github.oshai.kotlinlogging.Marker +import io.github.oshai.kotlinlogging.* import io.github.oshai.kotlinlogging.internal.toStringSafe import io.github.oshai.kotlinlogging.slf4j.toSlf4j import org.slf4j.event.EventConstants @@ -26,15 +22,13 @@ internal class LocationAwareKLogger(override val underlyingLogger: LocationAware private val fqcn: String = LocationAwareKLogger::class.java.name - private val ENTRY = io.github.oshai.kotlinlogging.KMarkerFactory.getMarker("ENTRY").toSlf4j() - private val EXIT = io.github.oshai.kotlinlogging.KMarkerFactory.getMarker("EXIT").toSlf4j() + private val ENTRY = KMarkerFactory.getMarker("ENTRY").toSlf4j() + private val EXIT = KMarkerFactory.getMarker("EXIT").toSlf4j() - private val THROWING = - io.github.oshai.kotlinlogging.KMarkerFactory.getMarker("THROWING").toSlf4j() - private val CATCHING = - io.github.oshai.kotlinlogging.KMarkerFactory.getMarker("CATCHING").toSlf4j() - private val EXITONLY = "exit" - private val EXITMESSAGE = "exit with ({})" + private val THROWING = KMarkerFactory.getMarker("THROWING").toSlf4j() + private val CATCHING = KMarkerFactory.getMarker("CATCHING").toSlf4j() + private val EXIT_ONLY = "exit" + private val EXIT_MESSAGE = "exit with ({})" override fun isLoggingEnabledFor(level: Level, marker: Marker?): Boolean { return isLoggingEnabledFor(underlyingLogger, level, marker) @@ -147,13 +141,13 @@ internal class LocationAwareKLogger(override val underlyingLogger: LocationAware override fun exit() { if (underlyingLogger.isTraceEnabled(EXIT)) { - underlyingLogger.log(EXIT, fqcn, EventConstants.TRACE_INT, EXITONLY, null, null) + underlyingLogger.log(EXIT, fqcn, EventConstants.TRACE_INT, EXIT_ONLY, null, null) } } override fun exit(result: T): T { if (underlyingLogger.isTraceEnabled(EXIT)) { - val tp = MessageFormatter.format(EXITMESSAGE, result) + val tp = MessageFormatter.format(EXIT_MESSAGE, result) underlyingLogger.log( EXIT, fqcn, diff --git a/src/jvmMain/kotlin/io/github/oshai/kotlinlogging/coroutines/KotlinLoggingAsyncMDC.kt b/src/jvmMain/kotlin/io/github/oshai/kotlinlogging/coroutines/KotlinLoggingAsyncMDC.kt index 6c4561c7..f499f6d6 100644 --- a/src/jvmMain/kotlin/io/github/oshai/kotlinlogging/coroutines/KotlinLoggingAsyncMDC.kt +++ b/src/jvmMain/kotlin/io/github/oshai/kotlinlogging/coroutines/KotlinLoggingAsyncMDC.kt @@ -1,8 +1,8 @@ package io.github.oshai.kotlinlogging.coroutines -import io.github.oshai.kotlinlogging.* -import kotlinx.coroutines.* -import kotlinx.coroutines.slf4j.* +import io.github.oshai.kotlinlogging.withLoggingContext +import kotlinx.coroutines.slf4j.MDCContext +import kotlinx.coroutines.withContext /** * Use a pair in an asynchronous MDC context. Example: diff --git a/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/coroutines/KotlinLoggingAsyncMDCTest.kt b/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/coroutines/KotlinLoggingAsyncMDCTest.kt index 18575438..27696c9a 100644 --- a/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/coroutines/KotlinLoggingAsyncMDCTest.kt +++ b/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/coroutines/KotlinLoggingAsyncMDCTest.kt @@ -1,12 +1,14 @@ package io.github.oshai.kotlinlogging.coroutines -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertNull import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest -import org.apache.logging.log4j.* -import org.apache.logging.log4j.core.config.* +import org.apache.logging.log4j.Level +import org.apache.logging.log4j.core.config.Configurator import org.junit.jupiter.api.BeforeEach -import org.slf4j.* +import org.slf4j.MDC @ExperimentalCoroutinesApi class KotlinLoggingAsyncMDCTest { diff --git a/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/internal/KLoggerNameResolverTest.kt b/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/internal/KLoggerNameResolverTest.kt index c7b9ddac..cb2d7c76 100644 --- a/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/internal/KLoggerNameResolverTest.kt +++ b/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/internal/KLoggerNameResolverTest.kt @@ -16,6 +16,7 @@ class KLoggerNameResolverTest { assertEquals(expectedName, KLoggerNameResolver.name(clazz)) } + @Suppress("UnusedPrivateMember") private fun testNames(): Stream = Stream.of( Arguments.of("io.github.oshai.kotlinlogging.internal.BaseClass", BaseClass::class.java), diff --git a/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/internal/MessageInvokerJavaTest.kt b/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/internal/MessageInvokerJavaTest.kt index 72aa59cc..9863d9ac 100644 --- a/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/internal/MessageInvokerJavaTest.kt +++ b/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/internal/MessageInvokerJavaTest.kt @@ -1,3 +1,5 @@ +@file:Suppress("TooGenericExceptionThrown") + package io.github.oshai.kotlinlogging.internal import kotlin.test.assertEquals diff --git a/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/jul/internal/JulLoggerWrapperTest.kt b/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/jul/internal/JulLoggerWrapperTest.kt index 5a66094c..548a335c 100644 --- a/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/jul/internal/JulLoggerWrapperTest.kt +++ b/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/jul/internal/JulLoggerWrapperTest.kt @@ -1,14 +1,11 @@ package io.github.oshai.kotlinlogging.jul.internal -import io.github.oshai.kotlinlogging.AppenderWithWriter -import io.github.oshai.kotlinlogging.KLogger -import io.github.oshai.kotlinlogging.KotlinLogging -import io.github.oshai.kotlinlogging.addAppender -import io.github.oshai.kotlinlogging.removeAppender +import io.github.oshai.kotlinlogging.* import java.util.logging.Level import java.util.logging.Logger import org.junit.jupiter.api.AfterAll -import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test import org.slf4j.bridge.SLF4JBridgeHandler