From 048ae6b0743226429b108675bac28ac8ffc865f6 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Fri, 20 Dec 2024 21:46:20 +0100 Subject: [PATCH] Add subsystem version to log messages --- .../de/staropensource/engine/base/Engine.kt | 15 +++++++++------ .../engine/base/implementable/Subsystem.kt | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/base/src/main/kotlin/de/staropensource/engine/base/Engine.kt b/base/src/main/kotlin/de/staropensource/engine/base/Engine.kt index 2b1e2c9..9e684a6 100644 --- a/base/src/main/kotlin/de/staropensource/engine/base/Engine.kt +++ b/base/src/main/kotlin/de/staropensource/engine/base/Engine.kt @@ -226,7 +226,7 @@ class Engine private constructor() { subsystem.initialize() } catch (throwable: Throwable) { logger.crash( - "Failed to initialize subsystem '${subsystem.getName()}' [${subsystem::class.qualifiedName ?: ""}]", + "Failed to initialize subsystem '${subsystem.getName()}'@'${subsystem.getVersion()}' [${subsystem::class.qualifiedName ?: ""}]", throwable = throwable, fatal = true ) @@ -280,11 +280,11 @@ class Engine private constructor() { logger.verb("Reloading subsystems") for (subsystem: Subsystem in subsystems) try { - logger.diag("Reloading subsystem '${subsystem.getName()}' [${subsystem::class.qualifiedName ?: ""}]") + logger.diag("Reloading subsystem '${subsystem.getName()}'@'${subsystem.getVersion()}' [${subsystem::class.qualifiedName ?: ""}]") subsystem.reload() } catch (throwable: Throwable) { logger.crash( - "Failed to reload subsystem '${subsystem.getName()}' [${subsystem::class.qualifiedName ?: ""}]", + "Failed to reload subsystem '${subsystem.getName()}'@'${subsystem.getVersion()}' [${subsystem::class.qualifiedName ?: ""}]", throwable = throwable, fatal = true ) @@ -384,17 +384,20 @@ class Engine private constructor() { // Initialize subsystems logger.verb("Shutting subsystems down") - for (subsystem: Subsystem in subsystems) + for (subsystem: Subsystem in subsystems) { + val subsystemVersion: String = subsystem.getVersion() + try { - logger.diag("Shutting subsystem '${subsystem.getName()}' [${subsystem::class.qualifiedName ?: ""}] down") + logger.diag("Shutting subsystem '${subsystem.getName()}'@'${subsystemVersion}' [${subsystem::class.qualifiedName ?: ""}] down") subsystem.shutdown(final = final, fatalCrash = crashed) } catch (throwable: Throwable) { logger.crash( - "Failed to shutdown subsystem '${subsystem.getName()}' [${subsystem::class.qualifiedName ?: ""}]", + "Failed to shutdown subsystem '${subsystem.getName()}'@'${subsystemVersion}' [${subsystem::class.qualifiedName ?: ""}]", throwable = throwable, fatal = true ) } + } // Print shutdown message if (final) diff --git a/base/src/main/kotlin/de/staropensource/engine/base/implementable/Subsystem.kt b/base/src/main/kotlin/de/staropensource/engine/base/implementable/Subsystem.kt index f94131d..bfb5a3d 100644 --- a/base/src/main/kotlin/de/staropensource/engine/base/implementable/Subsystem.kt +++ b/base/src/main/kotlin/de/staropensource/engine/base/implementable/Subsystem.kt @@ -36,8 +36,8 @@ abstract class Subsystem { /** * Returns the version of this subsystem. * - * Not called by the engine - * before [bootstrap]. + * Only called by the engine between + * [initialize] and [shutdown]. * * @return version * @since v1-alpha10