From 150416b578173c0e046c403a9ca8fb1f4e3f797b Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Mon, 16 Oct 2023 15:02:56 +0200 Subject: [PATCH] Fix/default log level (#719) * Set default log level to INFO Default log level was accidentally changed to ERROR for the base logger in 56deea9fb30961eb37de52ce2b85d3ec671ca018 * Reduce graphql log level to WARN Otherwise, thrown exceptions are swallowed by graphql and never logged besides a very brief error in the graphql response --- .../suwayomi/tachidesk/server/ServerSetup.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/ServerSetup.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/ServerSetup.kt index 3ac0f0c0..25776083 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/ServerSetup.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/ServerSetup.kt @@ -66,6 +66,16 @@ val serverConfig: ServerConfig by lazy { GlobalConfigManager.module() } val androidCompat by lazy { AndroidCompat() } +fun setupLogLevelUpdating( + configFlow: MutableStateFlow, + loggerNames: List, + defaultLevel: Level = Level.INFO, +) { + serverConfig.subscribeTo(configFlow, { debugLogsEnabled -> + loggerNames.forEach { loggerName -> setLogLevelFor(loggerName, if (debugLogsEnabled) Level.DEBUG else defaultLevel) } + }, ignoreInitialValue = false) +} + fun applicationSetup() { Thread.setDefaultUncaughtExceptionHandler { _, throwable -> KotlinLogging.logger { }.error(throwable) { "unhandled exception" } @@ -81,20 +91,10 @@ fun applicationSetup() { initLoggerConfig(applicationDirs.dataRoot) - val setupLogLevelUpdating = { configFlow: MutableStateFlow, loggerNames: List -> - serverConfig.subscribeTo(configFlow, { debugLogsEnabled -> - if (debugLogsEnabled) { - loggerNames.forEach { loggerName -> setLogLevelFor(loggerName, Level.DEBUG) } - } else { - loggerNames.forEach { loggerName -> setLogLevelFor(loggerName, Level.ERROR) } - } - }, ignoreInitialValue = false) - } - setupLogLevelUpdating(serverConfig.debugLogsEnabled, listOf(BASE_LOGGER_NAME)) // gql "ExecutionStrategy" spams logs with "... completing field ..." // gql "notprivacysafe" logs every received request multiple times (received, parsing, validating, executing) - setupLogLevelUpdating(serverConfig.gqlDebugLogsEnabled, listOf("graphql", "notprivacysafe")) + setupLogLevelUpdating(serverConfig.gqlDebugLogsEnabled, listOf("graphql", "notprivacysafe"), Level.WARN) logger.info("Running Tachidesk ${BuildConfig.VERSION} revision ${BuildConfig.REVISION}")