From a60a2b9be15bcdfb53b6626cd472e284762ef801 Mon Sep 17 00:00:00 2001 From: Moritz Zwerger Date: Mon, 20 Nov 2023 15:22:50 +0100 Subject: [PATCH] Log: start observing profile after loading Improves preboot performance a lot --- .../profile/profiles/other/OtherProfileManager.kt | 10 ++++++++-- .../config/profile/storage/StorageProfileManager.kt | 2 +- src/main/java/de/bixilon/minosoft/util/logging/Log.kt | 5 ++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/bixilon/minosoft/config/profile/profiles/other/OtherProfileManager.kt b/src/main/java/de/bixilon/minosoft/config/profile/profiles/other/OtherProfileManager.kt index 7e539cbf8..76686a4d8 100644 --- a/src/main/java/de/bixilon/minosoft/config/profile/profiles/other/OtherProfileManager.kt +++ b/src/main/java/de/bixilon/minosoft/config/profile/profiles/other/OtherProfileManager.kt @@ -13,16 +13,22 @@ package de.bixilon.minosoft.config.profile.profiles.other -import de.bixilon.kutil.json.MutableJsonObject +import com.fasterxml.jackson.databind.node.ObjectNode import de.bixilon.minosoft.config.profile.storage.StorageProfileManager +import de.bixilon.minosoft.util.logging.Log object OtherProfileManager : StorageProfileManager() { override val type get() = OtherProfile override val latestVersion get() = 3 - override fun migrate(version: Int, data: MutableJsonObject) = when (version) { + override fun migrate(version: Int, data: ObjectNode) = when (version) { 1 -> OtherProfileMigration.migrate1(data) 2 -> OtherProfileMigration.migrate2(data) else -> Unit } + + override fun load() { + super.load() + Log.observeProfile() + } } diff --git a/src/main/java/de/bixilon/minosoft/config/profile/storage/StorageProfileManager.kt b/src/main/java/de/bixilon/minosoft/config/profile/storage/StorageProfileManager.kt index d73ddaf5b..6a42f98a2 100644 --- a/src/main/java/de/bixilon/minosoft/config/profile/storage/StorageProfileManager.kt +++ b/src/main/java/de/bixilon/minosoft/config/profile/storage/StorageProfileManager.kt @@ -107,7 +107,7 @@ abstract class StorageProfileManager

: Iterable

, Identified { return load(storage, content) } - fun load() { + open fun load() { loadAll() } diff --git a/src/main/java/de/bixilon/minosoft/util/logging/Log.kt b/src/main/java/de/bixilon/minosoft/util/logging/Log.kt index 02239a4c6..26dcbbe33 100644 --- a/src/main/java/de/bixilon/minosoft/util/logging/Log.kt +++ b/src/main/java/de/bixilon/minosoft/util/logging/Log.kt @@ -59,7 +59,6 @@ object Log { QUEUE.take().print() } }, "Log").start() - OtherProfileManager::selected.observe(this) { this.levels = it.log.levels } ShutdownManager.addHook { ASYNC_LOGGING = false; catchAll { await() } } } @@ -199,4 +198,8 @@ object Log { } fun init() = Unit + + fun observeProfile() { + OtherProfileManager::selected.observe(this, true) { this.levels = it.log.levels } + } }