Log: start observing profile after loading

Improves preboot performance a lot
This commit is contained in:
Moritz Zwerger 2023-11-20 15:22:50 +01:00
parent 16df6decf7
commit a60a2b9be1
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
3 changed files with 13 additions and 4 deletions

View File

@ -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<OtherProfile>() {
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()
}
}

View File

@ -107,7 +107,7 @@ abstract class StorageProfileManager<P : Profile> : Iterable<P>, Identified {
return load(storage, content)
}
fun load() {
open fun load() {
loadAll()
}

View File

@ -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 }
}
}