From 99c4969f65b67285cdd421b5f1efc235c4829c29 Mon Sep 17 00:00:00 2001 From: Sigmund Marius Nilssen Date: Fri, 29 Nov 2024 08:47:19 +0100 Subject: [PATCH] Fix spotless --- .../oshai/kotlinlogging/AppenderWithWriter.kt | 2 - .../internal/LogbackLoggerWrapperTest.kt | 50 +++++++------------ 2 files changed, 17 insertions(+), 35 deletions(-) diff --git a/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/AppenderWithWriter.kt b/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/AppenderWithWriter.kt index 8117436..6e5c80f 100644 --- a/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/AppenderWithWriter.kt +++ b/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/AppenderWithWriter.kt @@ -4,8 +4,6 @@ import java.io.StringWriter import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.core.Appender import org.apache.logging.log4j.core.appender.WriterAppender -import org.apache.logging.log4j.core.config.json.JsonConfiguration -import org.apache.logging.log4j.core.layout.JsonLayout import org.apache.logging.log4j.core.layout.PatternLayout fun newPatternLayout(pattern: String): PatternLayout = diff --git a/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/logback/internal/LogbackLoggerWrapperTest.kt b/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/logback/internal/LogbackLoggerWrapperTest.kt index 6643ca1..8d78c6a 100644 --- a/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/logback/internal/LogbackLoggerWrapperTest.kt +++ b/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/logback/internal/LogbackLoggerWrapperTest.kt @@ -7,12 +7,11 @@ import ch.qos.logback.classic.spi.ILoggingEvent import ch.qos.logback.core.OutputStreamAppender import io.github.oshai.kotlinlogging.KLogger import io.github.oshai.kotlinlogging.KotlinLogging +import java.io.ByteArrayOutputStream import net.logstash.logback.argument.StructuredArguments -import net.logstash.logback.composite.JsonProviders import net.logstash.logback.composite.loggingevent.ArgumentsJsonProvider import net.logstash.logback.composite.loggingevent.LoggingEventPatternJsonProvider import net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder -import java.io.ByteArrayOutputStream import org.junit.jupiter.api.AfterAll import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.BeforeAll @@ -105,53 +104,38 @@ class LogbackLoggerWrapperTest { logger.info { "simple logback info message" } warnLogger.warn { "simple logback warn message" } errorLogger.error { "simple logback error message" } - val lines = - logOutputStream - .toByteArray() - .toString(Charsets.UTF_8) - .trim() - .lines() - val jsonLines = jsonLogOutputStream - .toByteArray() - .toString(Charsets.UTF_8) - .trim() - .lines() + val lines = logOutputStream.toByteArray().toString(Charsets.UTF_8).trim().lines() + val jsonLines = jsonLogOutputStream.toByteArray().toString(Charsets.UTF_8).trim().lines() assertEquals( "INFO io.github.oshai.kotlinlogging.logback.internal.LogbackLoggerWrapperTest - simple logback info message", lines[0], ) - assertEquals( - """{"message":"simple logback info message"}""", - jsonLines[0] - ) + assertEquals("""{"message":"simple logback info message"}""", jsonLines[0]) assertEquals("WARN warnLogger - simple logback warn message", lines[1]) assertEquals("""{"message":"simple logback warn message"}""", jsonLines[1]) assertEquals("ERROR errorLogger - simple logback error message", lines[2]) - assertEquals("""{"message":"simple logback error message"}""",jsonLines[2]) + assertEquals("""{"message":"simple logback error message"}""", jsonLines[2]) } @Test fun testLogbackLoggerWithArguments() { logger.atInfo { message = "msg" - arguments = arrayOf(StructuredArguments.keyValue("arg1", "val1"), StructuredArguments.keyValue("arg2", "val2")) + arguments = + arrayOf( + StructuredArguments.keyValue("arg1", "val1"), + StructuredArguments.keyValue("arg2", "val2"), + ) } - val lines = - logOutputStream - .toByteArray() - .toString(Charsets.UTF_8) - .trim() - .lines() - val jsonLines = jsonLogOutputStream - .toByteArray() - .toString(Charsets.UTF_8) - .trim() - .lines() + val lines = logOutputStream.toByteArray().toString(Charsets.UTF_8).trim().lines() + val jsonLines = jsonLogOutputStream.toByteArray().toString(Charsets.UTF_8).trim().lines() assertEquals(1, lines.size) assertEquals(1, jsonLines.size) - assertEquals("INFO io.github.oshai.kotlinlogging.logback.internal.LogbackLoggerWrapperTest - msg", lines[0]) - assertEquals("""{"message":"msg","arg1":"val1","arg2":"val2"}""",jsonLines[0]) + assertEquals( + "INFO io.github.oshai.kotlinlogging.logback.internal.LogbackLoggerWrapperTest - msg", + lines[0], + ) + assertEquals("""{"message":"msg","arg1":"val1","arg2":"val2"}""", jsonLines[0]) } - }