libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit 65b13c897dfe71319484040d2d6d33c6bb15d17e
parent 4266f98d262a3491a5a1e6184365ac99174a67f6
Author: MS <ms@taler.net>
Date:   Wed,  3 May 2023 14:36:19 +0200

help message to set the log level

Diffstat:
Mnexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 4+++-
Msandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 4+++-
Mutil/src/main/kotlin/Config.kt | 5++---
3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt @@ -95,7 +95,9 @@ class Serve : CliktCommand("Run nexus HTTP server") { } class ParseCamt : CliktCommand("Parse CAMT file, outputs JSON in libEufin internal representation.") { - private val logLevel by option() + private val logLevel by option( + help = "Set the log level to: 'off', 'error', 'warn', 'info', 'debug', 'trace', 'all'" + ) private val filename by argument("FILENAME", "File in CAMT format") override fun run() { setLogLevel(logLevel) diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt @@ -354,7 +354,9 @@ class Serve : CliktCommand("Run sandbox HTTP server") { "--ipv4-only", help = "Bind only to ipv4" ).flag(default = false) - private val logLevel by option() + private val logLevel by option( + help = "Set the log level to: 'off', 'error', 'warn', 'info', 'debug', 'trace', 'all'" + ) private val port by option().int().default(5000) private val withUnixSocket by option( help = "Bind the Sandbox to the Unix domain socket at PATH. Overrides" + diff --git a/util/src/main/kotlin/Config.kt b/util/src/main/kotlin/Config.kt @@ -2,7 +2,6 @@ package tech.libeufin.util import ch.qos.logback.classic.Level import ch.qos.logback.classic.LoggerContext -import ch.qos.logback.classic.util.ContextInitializer import ch.qos.logback.core.util.Loader import io.ktor.server.application.* import io.ktor.util.* @@ -32,13 +31,13 @@ fun getVersion(): String { * _and_ found under the calling classpath (= obeying to the same logback.xml) */ fun setLogLevel(logLevel: String?) { - when (val immutable = logLevel) { + when (logLevel) { is String -> { val ctx = LoggerFactory.getILoggerFactory() as LoggerContext val loggers: List<ch.qos.logback.classic.Logger> = ctx.loggerList loggers.forEach { if (it.name.contains("libeufin")) { - it.level = Level.toLevel(immutable) + it.level = Level.toLevel(logLevel) } } }