From ee23d7739d106c2c4f922ef737a23115e584313b Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Fri, 27 Dec 2024 23:51:17 +0100 Subject: [PATCH] Add AnsiSubsystem.makeFormattingDefault --- .../staropensource/engine/ansi/AnsiSubsystem.kt | 15 +++++++++++++++ .../de/staropensource/engine/testapp/Main.kt | 1 + 2 files changed, 16 insertions(+) diff --git a/ansi/src/main/kotlin/de/staropensource/engine/ansi/AnsiSubsystem.kt b/ansi/src/main/kotlin/de/staropensource/engine/ansi/AnsiSubsystem.kt index af6b799..a23ff8e 100644 --- a/ansi/src/main/kotlin/de/staropensource/engine/ansi/AnsiSubsystem.kt +++ b/ansi/src/main/kotlin/de/staropensource/engine/ansi/AnsiSubsystem.kt @@ -22,6 +22,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.type.logging.ChannelSettings import de.staropensource.engine.base.utility.dnihbd.BuildInformation /** @@ -95,4 +96,18 @@ class AnsiSubsystem : Subsystem() { override fun shutdown(final: Boolean, fatalCrash: Boolean) { info = null } + + + // -----> Miscellaneous + /** + * Makes the [AnsiFormatter] + * the default log formatter. + * + * @return this instance + * @since v1-alpha10 + */ + fun makeFormatterDefault(): AnsiSubsystem { + ChannelSettings.global = ChannelSettings.global.copy(formatter = AnsiFormatter.instance) + return this + } } diff --git a/testapp/src/main/kotlin/de/staropensource/engine/testapp/Main.kt b/testapp/src/main/kotlin/de/staropensource/engine/testapp/Main.kt index 034b473..7ef92bc 100644 --- a/testapp/src/main/kotlin/de/staropensource/engine/testapp/Main.kt +++ b/testapp/src/main/kotlin/de/staropensource/engine/testapp/Main.kt @@ -57,6 +57,7 @@ class Main private constructor() { // Register subsystems AnsiSubsystem.register() + (Engine.getSubsystem(AnsiSubsystem::class) as AnsiSubsystem?)?.makeFormatterDefault() // Initialize engine Engine.initialize()