mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[fleet] fix not showing some notifications in build (re-fix with no changes to LoggingContextContextElement)
GitOrigin-RevId: 80821b25dfe57a5a3468c9ef96414220a95f4caf
This commit is contained in:
committed by
intellij-monorepo-bot
parent
94fe0bfb7e
commit
37241ba0c3
@@ -1,17 +1,27 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package fleet.util.logging
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.ThreadContextElement
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlin.collections.plus
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.coroutines.coroutineContext
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
interface KLoggerFactory {
|
||||
fun logger(owner: KClass<*>): KLogger
|
||||
fun logger(owner: Any): KLogger
|
||||
fun logger(name: String): KLogger
|
||||
fun logger(owner: KClass<*>): KLogger
|
||||
fun logger(owner: Any): KLogger
|
||||
fun logger(name: String): KLogger
|
||||
|
||||
fun setLoggingContext(map: Map<String, String>?)
|
||||
fun getLoggingContext(): Map<String, String>?
|
||||
fun setLoggingContext(map: Map<String, String>?)
|
||||
fun getLoggingContext(): Map<String, String>?
|
||||
}
|
||||
|
||||
suspend fun <T> withAdditionalLoggingContext(addition: Map<String, String>, body: suspend CoroutineScope.() -> T): T {
|
||||
val currentContext = coroutineContext[LoggingContextContextElement]?.contextMap ?: emptyMap()
|
||||
val newContext = LoggingContextContextElement(currentContext + addition)
|
||||
return withContext(newContext, body)
|
||||
}
|
||||
|
||||
class LoggingContextContextElement(val contextMap: Map<String, String>?) : ThreadContextElement<Map<String, String>?> {
|
||||
@@ -28,4 +38,5 @@ class LoggingContextContextElement(val contextMap: Map<String, String>?) : Threa
|
||||
override val key: CoroutineContext.Key<*> get() = LoggingContextContextElement
|
||||
|
||||
companion object : CoroutineContext.Key<LoggingContextContextElement>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user