From 86456150045fa20c3d1da6c8f742a1f73cd3451a Mon Sep 17 00:00:00 2001 From: oshai Date: Wed, 12 Jul 2023 21:58:08 +0300 Subject: [PATCH] add failing test for https://github.com/apache/logging-log4j2/issues/1533 --- .../kotlinlogging/ClassWithLoggingForLocationTesting.kt | 7 +++++++ .../oshai/kotlinlogging/LoggingWithLocationTest.kt | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/ClassWithLoggingForLocationTesting.kt b/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/ClassWithLoggingForLocationTesting.kt index bf9440b2..f5dc1075 100644 --- a/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/ClassWithLoggingForLocationTesting.kt +++ b/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/ClassWithLoggingForLocationTesting.kt @@ -27,4 +27,11 @@ class ClassWithLoggingForLocationTesting { logger.info { "log entry body" } return logger.exit(null) } + + fun logFluentWithPayload() { + logger.atInfo { + message = "test" + payload = mapOf("key" to "value") + } + } } diff --git a/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/LoggingWithLocationTest.kt b/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/LoggingWithLocationTest.kt index 518cf9c8..726958b8 100644 --- a/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/LoggingWithLocationTest.kt +++ b/src/jvmTest/kotlin/io/github/oshai/kotlinlogging/LoggingWithLocationTest.kt @@ -42,6 +42,15 @@ class LoggingWithLocationTest { ) } + @Test + fun testFluentLoggingWithLocation() { + ClassWithLoggingForLocationTesting().logFluentWithPayload() + assertEquals( + "INFO ClassWithLoggingForLocationTesting.logFluentWithPayload(32) - test", + appenderWithWriter.writer.toString().trim() + ) + } + @Test fun testNullLoggingWithLocation() { ClassWithLoggingForLocationTesting().logNull()