Skip to content

Commit fe7b022

Browse files
committed
Add docs about context and coroutines integration
1 parent 188ccfe commit fe7b022

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/site/index.adoc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,26 @@ assert(message == ContextStack.pop())
138138
assert(ContextStack.empty)
139139
----
140140
141+
A `CoroutineThreadContext` context element is provided to integrate logging context with coroutines.
142+
143+
[source,kotlin]
144+
----
145+
launch(loggingContext(mapOf("myKey" to "myValue"), listOf("test"))) {
146+
assertEquals("myValue", ContextMap["myKey"])
147+
assertEquals("test", ContextStack.peek())
148+
}
149+
----
150+
151+
or to preserve the existing context:
152+
153+
[source,kotlin]
154+
----
155+
launch(additionalLoggingContext(mapOf("myKey" to "myValue"), listOf("test"))) {
156+
assertEquals("myValue", ContextMap["myKey"])
157+
assertEquals("test", ContextStack.peek())
158+
}
159+
----
160+
141161
[#params]
142162
== Parameter substitution
143163

0 commit comments

Comments
 (0)