Add register method and version checks to the ANSI subsystem
This commit is contained in:
parent
3421fe55bf
commit
cd81e60808
2 changed files with 31 additions and 0 deletions
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package de.staropensource.engine.ansi
|
package de.staropensource.engine.ansi
|
||||||
|
|
||||||
|
import de.staropensource.engine.base.Engine
|
||||||
import de.staropensource.engine.base.implementable.Subsystem
|
import de.staropensource.engine.base.implementable.Subsystem
|
||||||
import de.staropensource.engine.base.logging.Logger
|
import de.staropensource.engine.base.logging.Logger
|
||||||
import de.staropensource.engine.base.utility.dnihbd.BuildInformation
|
import de.staropensource.engine.base.utility.dnihbd.BuildInformation
|
||||||
|
@ -40,6 +41,7 @@ class AnsiSubsystem : Subsystem() {
|
||||||
*
|
*
|
||||||
* @since v1-alpha10
|
* @since v1-alpha10
|
||||||
*/
|
*/
|
||||||
|
@JvmStatic
|
||||||
internal val logger: Logger = Logger(channel = "engine-ansi")
|
internal val logger: Logger = Logger(channel = "engine-ansi")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,7 +52,19 @@ class AnsiSubsystem : Subsystem() {
|
||||||
* @see BuildInformation
|
* @see BuildInformation
|
||||||
* @since v1-alpha10
|
* @since v1-alpha10
|
||||||
*/
|
*/
|
||||||
|
@JvmStatic
|
||||||
var info: BuildInformation? = null
|
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
|
// -----> Lifecycle
|
||||||
override fun initialize() {
|
override fun initialize() {
|
||||||
info = BuildInformation("sosengine-ansi")
|
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) {
|
override fun shutdown(final: Boolean, fatalCrash: Boolean) {
|
||||||
|
|
|
@ -54,6 +54,9 @@ class Main private constructor() {
|
||||||
// Update engine configuration
|
// Update engine configuration
|
||||||
EngineConfiguration.logLevels = Level.entries.toMutableSet()
|
EngineConfiguration.logLevels = Level.entries.toMutableSet()
|
||||||
|
|
||||||
|
// Register subsystems
|
||||||
|
AnsiSubsystem.register()
|
||||||
|
|
||||||
// Initialize engine
|
// Initialize engine
|
||||||
Engine.initialize()
|
Engine.initialize()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue