This is an automated email from the ASF dual-hosted git repository.
rgupta pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/logging-log4j-kotlin.git
The following commit(s) were added to refs/heads/main by this push:
new 325a568 Handle context stack push parameters (#151)
325a568 is described below
commit 325a5689cef77ed810852064da1ad83aa7d3f63b
Author: Raman Gupta <[email protected]>
AuthorDate: Wed Apr 1 11:01:25 2026 -0400
Handle context stack push parameters (#151)
* Handle context stack push parameters
* Fix changelog
* Apply suggestion from @vy
---------
Co-authored-by: Volkan Yazıcı <[email protected]>
---
.../apache/logging/log4j/kotlin/ContextStack.kt | 2 +-
.../ContextStackPushTest.kt | 46 ++++++++++++++++++++++
.../.1.x.x/context_stack_wrapper_push_fix.xml | 10 +++++
3 files changed, 57 insertions(+), 1 deletion(-)
diff --git
a/log4j-api-kotlin/src/main/kotlin/org/apache/logging/log4j/kotlin/ContextStack.kt
b/log4j-api-kotlin/src/main/kotlin/org/apache/logging/log4j/kotlin/ContextStack.kt
index 4d298a1..6a525a2 100644
---
a/log4j-api-kotlin/src/main/kotlin/org/apache/logging/log4j/kotlin/ContextStack.kt
+++
b/log4j-api-kotlin/src/main/kotlin/org/apache/logging/log4j/kotlin/ContextStack.kt
@@ -103,7 +103,7 @@ object ContextStack {
*
* @see ThreadContext.push
*/
- fun push(message: String, vararg args: Any?) = ThreadContext.push(message,
args)
+ fun push(message: String, vararg args: Any?) = ThreadContext.push(message,
*args)
/**
* Trims the current context stack to at most the given depth.
diff --git
a/log4j-api-kotlin/src/test/kotlin/org.apache.logging.log4j.kotlin/ContextStackPushTest.kt
b/log4j-api-kotlin/src/test/kotlin/org.apache.logging.log4j.kotlin/ContextStackPushTest.kt
new file mode 100644
index 0000000..3933088
--- /dev/null
+++
b/log4j-api-kotlin/src/test/kotlin/org.apache.logging.log4j.kotlin/ContextStackPushTest.kt
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.kotlin
+
+import org.junit.jupiter.api.AfterEach
+import org.junit.jupiter.api.Test
+import kotlin.test.assertEquals
+
+class ContextStackPushTest {
+ @AfterEach
+ fun tearDown() {
+ ContextStack.clear()
+ }
+
+ @Test
+ fun `Single parameter push keeps value format`() {
+ ContextStack.push("user={}", "admin")
+ assertEquals("user=admin", ContextStack.peek())
+ }
+
+ @Test
+ fun `Parameterized push keeps second parameter`() {
+ ContextStack.push("user={} action={}", "admin", "login")
+ assertEquals("user=admin action=login", ContextStack.peek())
+ }
+
+ @Test
+ fun `Parameterized push keeps third parameter`() {
+ ContextStack.push("a={} b={} c={}", "1", "2", "3")
+ assertEquals("a=1 b=2 c=3", ContextStack.peek())
+ }
+}
diff --git a/src/changelog/.1.x.x/context_stack_wrapper_push_fix.xml
b/src/changelog/.1.x.x/context_stack_wrapper_push_fix.xml
new file mode 100644
index 0000000..3bf2010
--- /dev/null
+++ b/src/changelog/.1.x.x/context_stack_wrapper_push_fix.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="https://logging.apache.org/xml/ns"
+ xsi:schemaLocation="https://logging.apache.org/xml/ns
https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
+ type="fixed">
+ <issue id="145"
link="https://github.com/apache/logging-log4j-kotlin/issues/145"/>
+ <issue id="146"
link="https://github.com/apache/logging-log4j-kotlin/issues/146"/>
+ <issue id="151"
link="https://github.com/apache/logging-log4j-kotlin/pull/151"/>
+ <description format="asciidoc">Context stack push parameters are handled
correctly</description>
+</entry>