mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-27 13:13:43 +00:00
Make our loggers singletons.
This commit is contained in:
committed by
Cody Henthorne
parent
ec7a2f734a
commit
26df14124b
@@ -334,7 +334,7 @@ public class ApplicationContext extends Application implements AppForegroundObse
|
||||
|
||||
@VisibleForTesting
|
||||
protected void initializeLogging() {
|
||||
Log.initialize(RemoteConfig::internalUser, new AndroidLogger(), new PersistentLogger(this));
|
||||
Log.initialize(RemoteConfig::internalUser, AndroidLogger.INSTANCE, PersistentLogger.getInstance(this));
|
||||
|
||||
SignalProtocolLoggerProvider.setProvider(new CustomSignalProtocolLogger());
|
||||
SignalProtocolLoggerProvider.initializeLogging(BuildConfig.LIBSIGNAL_LOG_LEVEL);
|
||||
|
||||
@@ -25,9 +25,7 @@ import java.util.Locale
|
||||
* - Main thread creates a [LogRequest] object and puts it in a queue
|
||||
* - The [WriteThread] constantly pulls from that queue, formats the logs, and writes them to the database.
|
||||
*/
|
||||
class PersistentLogger(
|
||||
application: Application
|
||||
) : Log.Logger() {
|
||||
class PersistentLogger private constructor(application: Application) : Log.Logger() {
|
||||
|
||||
companion object {
|
||||
private const val LOG_V = "V"
|
||||
@@ -35,6 +33,22 @@ class PersistentLogger(
|
||||
private const val LOG_I = "I"
|
||||
private const val LOG_W = "W"
|
||||
private const val LOG_E = "E"
|
||||
|
||||
@Volatile
|
||||
private var instance: PersistentLogger? = null
|
||||
|
||||
@JvmStatic
|
||||
fun getInstance(application: Application): PersistentLogger {
|
||||
if (instance == null) {
|
||||
synchronized(PersistentLogger::class.java) {
|
||||
if (instance == null) {
|
||||
instance = PersistentLogger(application)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return requireNotNull(instance)
|
||||
}
|
||||
}
|
||||
|
||||
private val logEntries = LogRequests()
|
||||
|
||||
@@ -78,7 +78,7 @@ class AvatarProvider : BaseContentProvider() {
|
||||
|
||||
SignalStore.init(application)
|
||||
|
||||
Log.initialize(RemoteConfig::internalUser, AndroidLogger(), PersistentLogger(application))
|
||||
Log.initialize(RemoteConfig::internalUser, AndroidLogger, PersistentLogger.getInstance(application))
|
||||
|
||||
if (!AppDependencies.isInitialized) {
|
||||
Log.i(TAG, "Initializing AppDependencies.")
|
||||
|
||||
Reference in New Issue
Block a user