Add register method and version checks to the ANSI subsystem
Some checks failed
PRs & Pushes / test (push) Failing after 2m17s
PRs & Pushes / build (push) Failing after 16m20s
PRs & Pushes / build-apidoc (push) Failing after 22m23s

This commit is contained in:
JeremyStar™ 2024-12-20 21:59:19 +01:00
parent 3421fe55bf
commit cd81e60808
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
2 changed files with 31 additions and 0 deletions

View file

@ -19,6 +19,7 @@
package de.staropensource.engine.ansi
import de.staropensource.engine.base.Engine
import de.staropensource.engine.base.implementable.Subsystem
import de.staropensource.engine.base.logging.Logger
import de.staropensource.engine.base.utility.dnihbd.BuildInformation
@ -40,6 +41,7 @@ class AnsiSubsystem : Subsystem() {
*
* @since v1-alpha10
*/
@JvmStatic
internal val logger: Logger = Logger(channel = "engine-ansi")
/**
@ -50,7 +52,19 @@ class AnsiSubsystem : Subsystem() {
* @see BuildInformation
* @since v1-alpha10
*/
@JvmStatic
var info: BuildInformation? = null
/**
* Registers this subsystem.
*
* @since v1-alpha10
*/
@JvmStatic
fun register() {
if (!Engine.getSubsystems().map { item -> item::class }.contains(AnsiSubsystem::class))
Engine.registerSubsystem(AnsiSubsystem())
}
}
@ -62,6 +76,20 @@ class AnsiSubsystem : Subsystem() {
// -----> Lifecycle
override fun initialize() {
info = BuildInformation("sosengine-ansi")
if (Engine.info!!.versionString(semver = false) != info!!.versionString(semver = false))
logger.crash("""
The version of the core engine and the ANSI subsystem differs.
Engine: ${Engine.info!!.versionString(semver = false)}
ANSI subsystem: ${info!!.versionString(semver = false)}
""".trimIndent().trimEnd())
if (Engine.info!!.gitCommitIdentifierLong != info!!.gitCommitIdentifierLong)
logger.crash("""
The commit id of the core engine and the ANSI subsystem differs.
Engine: ${Engine.info!!.gitCommitIdentifierLong}
ANSI subsystem: ${info!!.gitCommitIdentifierLong}
""".trimIndent().trimEnd())
}
override fun shutdown(final: Boolean, fatalCrash: Boolean) {

View file

@ -54,6 +54,9 @@ class Main private constructor() {
// Update engine configuration
EngineConfiguration.logLevels = Level.entries.toMutableSet()
// Register subsystems
AnsiSubsystem.register()
// Initialize engine
Engine.initialize()