Use new APIs for debug logs
This commit is contained in:
parent
49fb77f0be
commit
7e6530504a
4 changed files with 26 additions and 14 deletions
|
@ -22,10 +22,7 @@ package org.linphone
|
|||
import android.annotation.SuppressLint
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import org.linphone.core.CoreContext
|
||||
import org.linphone.core.CorePreferences
|
||||
import org.linphone.core.Factory
|
||||
import org.linphone.core.LogCollectionState
|
||||
import org.linphone.core.*
|
||||
import org.linphone.core.tools.Log
|
||||
|
||||
class LinphoneApplication : Application() {
|
||||
|
@ -55,7 +52,11 @@ class LinphoneApplication : Application() {
|
|||
corePreferences.config = config
|
||||
|
||||
val appName = context.getString(R.string.app_name)
|
||||
Factory.instance().setDebugMode(corePreferences.debugLogs, appName)
|
||||
Factory.instance().setLoggerDomain(appName)
|
||||
Factory.instance().enableLogcatLogs(corePreferences.logcatLogsOutput)
|
||||
if (corePreferences.debugLogs) {
|
||||
Factory.instance().loggingService.setLogLevel(LogLevel.Message)
|
||||
}
|
||||
|
||||
Log.i("[Application] Core context created ${if (pushReceived) "from push" else ""}")
|
||||
coreContext = CoreContext(context, config)
|
||||
|
|
|
@ -27,8 +27,8 @@ import org.linphone.activities.main.settings.SettingListenerStub
|
|||
import org.linphone.activities.main.viewmodels.LogsUploadViewModel
|
||||
import org.linphone.core.CoreContext
|
||||
import org.linphone.core.Factory
|
||||
import org.linphone.core.LogLevel
|
||||
import org.linphone.mediastream.Version
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.Event
|
||||
|
||||
class AdvancedSettingsViewModel : LogsUploadViewModel() {
|
||||
|
@ -38,8 +38,8 @@ class AdvancedSettingsViewModel : LogsUploadViewModel() {
|
|||
val debugModeListener = object : SettingListenerStub() {
|
||||
override fun onBoolValueChanged(newValue: Boolean) {
|
||||
prefs.debugLogs = newValue
|
||||
val appName = AppUtils.getString(R.string.app_name)
|
||||
Factory.instance().setDebugMode(prefs.debugLogs, appName)
|
||||
val logLevel = if (newValue) LogLevel.Message else LogLevel.Error
|
||||
Factory.instance().loggingService.setLogLevel(logLevel)
|
||||
}
|
||||
}
|
||||
val debugMode = MutableLiveData<Boolean>()
|
||||
|
|
|
@ -266,12 +266,14 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
|||
level: LogLevel,
|
||||
message: String
|
||||
) {
|
||||
when (level) {
|
||||
LogLevel.Error -> android.util.Log.e(domain, message)
|
||||
LogLevel.Warning -> android.util.Log.w(domain, message)
|
||||
LogLevel.Message -> android.util.Log.i(domain, message)
|
||||
LogLevel.Fatal -> android.util.Log.wtf(domain, message)
|
||||
else -> android.util.Log.d(domain, message)
|
||||
if (corePreferences.logcatLogsOutput) {
|
||||
when (level) {
|
||||
LogLevel.Error -> android.util.Log.e(domain, message)
|
||||
LogLevel.Warning -> android.util.Log.w(domain, message)
|
||||
LogLevel.Message -> android.util.Log.i(domain, message)
|
||||
LogLevel.Fatal -> android.util.Log.wtf(domain, message)
|
||||
else -> android.util.Log.d(domain, message)
|
||||
}
|
||||
}
|
||||
FirebaseCrashlytics.getInstance().log("[$domain] [${level.name}] $message")
|
||||
}
|
||||
|
|
|
@ -64,6 +64,9 @@ class CorePreferences constructor(private val context: Context) {
|
|||
return
|
||||
}
|
||||
encryptedSharedPreferences.edit().putBoolean("vfs_enabled", value).apply()
|
||||
// When VFS is enabled we disable logcat output for linphone logs
|
||||
// TODO: decide if we do it
|
||||
// logcatLogsOutput = false
|
||||
}
|
||||
|
||||
/* App settings */
|
||||
|
@ -74,6 +77,12 @@ class CorePreferences constructor(private val context: Context) {
|
|||
config.setBool("app", "debug", value)
|
||||
}
|
||||
|
||||
var logcatLogsOutput: Boolean
|
||||
get() = config.getBool("app", "print_logs_into_logcat", true)
|
||||
set(value) {
|
||||
config.setBool("app", "print_logs_into_logcat", value)
|
||||
}
|
||||
|
||||
var autoStart: Boolean
|
||||
get() = config.getBool("app", "auto_start", true)
|
||||
set(value) {
|
||||
|
|
Loading…
Reference in a new issue