Skip to content

Commit 258af81

Browse files
committed
AND-19314 Add Mutex to Reset Logging Configuration
(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>
1 parent dcc48f6 commit 258af81

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

data/src/main/java/mega/privacy/android/data/gateway/LogbackLogConfigurationGateway.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,24 @@ import java.io.File
1212
import java.io.IOException
1313
import java.io.InputStream
1414
import javax.inject.Inject
15+
import javax.inject.Singleton
16+
import kotlinx.coroutines.sync.Mutex
17+
import kotlinx.coroutines.sync.withLock
1518

1619

1720
/**
1821
* Logback log configuration gateway implementation of [LogConfigurationGateway]
1922
*
2023
* @property context
2124
*/
25+
@Singleton
2226
class LogbackLogConfigurationGateway @Inject constructor(
2327
@ApplicationContext private val context: Context,
24-
@LogFileDirectory private val logFileDirectory: Lazy<File>
28+
@LogFileDirectory private val logFileDirectory: Lazy<File>,
2529
) : LogConfigurationGateway {
30+
private val mutex = Mutex()
2631

27-
override suspend fun resetLoggingConfiguration() {
32+
override suspend fun resetLoggingConfiguration() = mutex.withLock {
2833
val loggingContext = LoggerFactory.getILoggerFactory() as LoggerContext
2934
val loggers = loggingContext.copyOfListenerList
3035
loggingContext.reset()

0 commit comments

Comments
 (0)