Make log level setting changes immediately active

This commit is contained in:
lynxnb 2022-02-18 13:20:56 +01:00 committed by ◱ Mark
parent bb4937121f
commit f734c4d145
4 changed files with 32 additions and 1 deletions

View File

@ -237,3 +237,7 @@ extern "C" JNIEXPORT void JNICALL Java_emu_skyline_utils_SettingsValues_updateNa
return; // We don't mind if we miss settings updates while settings haven't been initialized
settings->Update();
}
extern "C" JNIEXPORT void JNICALL Java_emu_skyline_utils_SettingsValues_00024Companion_setLogLevel(JNIEnv *, jobject, jint logLevel) {
skyline::Logger::configLevel = static_cast<skyline::Logger::LogLevel>(logLevel);
}

View File

@ -0,0 +1,20 @@
/*
* SPDX-License-Identifier: MPL-2.0
* Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/)
*/
package emu.skyline.preference
import android.content.Context
import android.util.AttributeSet
import androidx.preference.R
import emu.skyline.utils.SettingsValues
class LogLevelPreference @JvmOverloads constructor(context : Context, attrs : AttributeSet? = null, defStyleAttr : Int = R.attr.dialogPreferenceStyle) : IntegerListPreference(context, attrs, defStyleAttr) {
init {
setOnPreferenceChangeListener { _, newValue ->
SettingsValues.setLogLevel(newValue as Int)
true
}
}
}

View File

@ -18,4 +18,11 @@ class SettingsValues(pref: PreferenceSettings) : Serializable {
* Updates settings in libskyline during emulation
*/
external fun updateNative()
companion object {
/**
* Setter for native log level
*/
external fun setLogLevel(logLevel : Int)
}
}

View File

@ -34,7 +34,7 @@
android:summaryOn="@string/perf_stats_desc_on"
app:key="perf_stats"
app:title="@string/perf_stats" />
<emu.skyline.preference.IntegerListPreference
<emu.skyline.preference.LogLevelPreference
android:defaultValue="2"
android:entries="@array/log_level"
app:key="log_level"