Skip to content

Commit

Permalink
AND-19314 Add Mutex to Reset Logging Configuration
Browse files Browse the repository at this point in the history
(cherry picked from commit 3134d51)

baeb540a VPN-19314 Add Mutex to Reset Logging Configuration
b22280ad change to =

Co-authored-by: Kevin Gozali <kg@mega.co.nz>
  • Loading branch information
kevingoz committed Sep 18, 2024
1 parent dcc48f6 commit 258af81
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,24 @@ import java.io.File
import java.io.IOException
import java.io.InputStream
import javax.inject.Inject
import javax.inject.Singleton
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock


/**
* Logback log configuration gateway implementation of [LogConfigurationGateway]
*
* @property context
*/
@Singleton
class LogbackLogConfigurationGateway @Inject constructor(
@ApplicationContext private val context: Context,
@LogFileDirectory private val logFileDirectory: Lazy<File>
@LogFileDirectory private val logFileDirectory: Lazy<File>,
) : LogConfigurationGateway {
private val mutex = Mutex()

override suspend fun resetLoggingConfiguration() {
override suspend fun resetLoggingConfiguration() = mutex.withLock {
val loggingContext = LoggerFactory.getILoggerFactory() as LoggerContext
val loggers = loggingContext.copyOfListenerList
loggingContext.reset()
Expand Down

0 comments on commit 258af81

Please sign in to comment.